@@ -8,7 +8,7 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
8
8
var
9
9
graphs = config . getGraphs ( ) ,
10
10
i , j ;
11
-
11
+
12
12
targetElem . empty ( ) ;
13
13
14
14
for ( i = 0 ; i < graphs . length ; i ++ ) {
@@ -27,10 +27,11 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
27
27
li = $ ( '<li class="graph-legend-field field-quick-adjust" name="' + field . name + '" graph="' + i + '" field="' + j + '"></li>' ) ,
28
28
nameElem = $ ( '<span class="graph-legend-field-name field-quick-adjust" name="' + field . name + '" graph="' + i + '" field="' + j + '"></span>' ) ,
29
29
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>' ) ;
32
33
li . append ( nameElem ) ;
33
- li . append ( analyseElem ) ;
34
+ li . append ( visibilityElem ) ;
34
35
li . append ( valueElem ) ;
35
36
li . append ( settingsElem ) ;
36
37
@@ -63,7 +64,7 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
63
64
} ) ;
64
65
65
66
// 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 ) {
67
68
68
69
if ( e . which != 1 ) return ; // only accept left mouse clicks
69
70
@@ -134,7 +135,31 @@ function GraphLegend(targetElem, config, onVisibilityChange, onNewSelectionChang
134
135
} ) ;
135
136
136
137
// 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
+ } ) ;
138
163
}
139
164
140
165
this . updateValues = function ( flightLog , frame ) {
0 commit comments