@@ -8,7 +8,7 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
88 var
99 graphs = config . getGraphs ( ) ,
1010 i , j ;
11-
11+
1212 targetElem . empty ( ) ;
1313
1414 for ( i = 0 ; i < graphs . length ; i ++ ) {
@@ -27,10 +27,11 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
2727 li = $ ( '<li class="graph-legend-field field-quick-adjust" name="' + field . name + '" graph="' + i + '" field="' + j + '"></li>' ) ,
2828 nameElem = $ ( '<span class="graph-legend-field-name field-quick-adjust" name="' + field . name + '" graph="' + i + '" field="' + j + '"></span>' ) ,
2929 valueElem = $ ( '<span class="graph-legend-field-value field-quick-adjust" name="' + field . name + '" graph="' + i + '" field="' + j + '"></span>' ) ,
30- settingsElem = $ ( '<div class="graph-legend-field-settings field-quick-adjust" name="' + field . name + '" graph="' + i + '" field="' + j + '"></div>' ) ,
31- analyseElem = $ ( '<span class="glyphicon glyphicon-equalizer"></span>' ) ;
30+ settingsElem = $ ( '<div class="graph-legend-field-settings field-quick-adjust" name="' + field . name + '" graph="' + i + '" field="' + j + '"></div>' ) ,
31+ visibilityIcon = config . isGraphFieldHidden ( i , j ) ? "glyphicon-eye-close" : "glyphicon-eye-open" ,
32+ visibilityElem = $ ( '<span class="glyphicon ' + visibilityIcon + ' graph-legend-field-visibility" graph="' + i + '" field="' + j + '"></span>' ) ;
3233 li . append ( nameElem ) ;
33- li . append ( analyseElem ) ;
34+ li . append ( visibilityElem ) ;
3435 li . append ( valueElem ) ;
3536 li . append ( settingsElem ) ;
3637
@@ -63,7 +64,7 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
6364 } ) ;
6465
6566 // Add a trigger on legend; select the analyser graph/field to plot
66- $ ( '.graph-legend-field' ) . on ( 'click' , function ( e ) {
67+ $ ( '.graph-legend-field-name, .graph-legend-field-settings, .graph-legend-field-value ' ) . on ( 'click' , function ( e ) {
6768
6869 if ( e . which != 1 ) return ; // only accept left mouse clicks
6970
@@ -134,7 +135,31 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
134135 } ) ;
135136
136137 // on first show, hide the analyser button
137- if ( ! config . selectedFieldName ) $ ( '.hide-analyser-window' ) . hide ( ) ;
138+ if ( ! config . selectedFieldName ) $ ( '.hide-analyser-window' ) . hide ( ) ;
139+
140+ // Add a trigger on legend; select the analyser graph/field to plot
141+ $ ( '.graph-legend-field-visibility' ) . on ( 'click' , function ( e ) {
142+ if ( e . which != 1 ) {
143+ return ; // only accept left mouse clicks
144+ }
145+
146+ const $this = $ ( this ) ,
147+ graphIndex = $this . attr ( 'graph' ) ,
148+ fieldIndex = $this . attr ( 'field' ) ;
149+
150+ config . toggleGraphField ( graphIndex , fieldIndex ) ;
151+ onHighlightChange ( ) ;
152+
153+ if ( config . isGraphFieldHidden ( graphIndex , fieldIndex ) ) {
154+ $this . removeClass ( "glyphicon-eye-open" ) ;
155+ $this . addClass ( "glyphicon-eye-close" ) ;
156+ } else {
157+ $this . addClass ( "glyphicon-eye-open" ) ;
158+ $this . removeClass ( "glyphicon-eye-close" ) ;
159+ }
160+
161+ e . preventDefault ( ) ;
162+ } ) ;
138163 }
139164
140165 this . updateValues = function ( flightLog , frame ) {
0 commit comments