@@ -12,6 +12,7 @@ module.exports = function handleClick(g, gd, numClicks) {
12
12
13
13
var itemClick = fullLayout . legend . itemclick ;
14
14
var itemDoubleClick = fullLayout . legend . itemdoubleclick ;
15
+ var groupClick = fullLayout . legend . groupclick ;
15
16
16
17
if ( numClicks === 1 && itemClick === 'toggle' && itemDoubleClick === 'toggleothers' &&
17
18
SHOWISOLATETIP && gd . data && gd . _context . showTips
@@ -27,6 +28,8 @@ module.exports = function handleClick(g, gd, numClicks) {
27
28
else if ( numClicks === 2 ) mode = itemDoubleClick ;
28
29
if ( ! mode ) return ;
29
30
31
+ var toggleGroup = groupClick === undefined || groupClick === "togglegroup" ;
32
+
30
33
var hiddenSlices = fullLayout . hiddenlabels ?
31
34
fullLayout . hiddenlabels . slice ( ) :
32
35
[ ] ;
@@ -148,10 +151,16 @@ module.exports = function handleClick(g, gd, numClicks) {
148
151
}
149
152
150
153
if ( hasLegendgroup ) {
151
- for ( i = 0 ; i < fullData . length ; i ++ ) {
152
- if ( fullData [ i ] . visible !== false && fullData [ i ] . legendgroup === legendgroup ) {
153
- setVisibility ( fullData [ i ] , nextVisibility ) ;
154
+ if ( groupClick === false ) return ;
155
+
156
+ if ( toggleGroup ) {
157
+ for ( i = 0 ; i < fullData . length ; i ++ ) {
158
+ if ( fullData [ i ] . visible !== false && fullData [ i ] . legendgroup === legendgroup ) {
159
+ setVisibility ( fullData [ i ] , nextVisibility ) ;
160
+ }
154
161
}
162
+ } else {
163
+ setVisibility ( fullTrace , nextVisibility ) ;
155
164
}
156
165
} else {
157
166
setVisibility ( fullTrace , nextVisibility ) ;
@@ -192,7 +201,8 @@ module.exports = function handleClick(g, gd, numClicks) {
192
201
// N.B. consider traces that have a set legendgroup as toggleable
193
202
notInLegend = ( fullData [ i ] . showlegend !== true && ! fullData [ i ] . legendgroup ) ;
194
203
isInGroup = isClicked || ( hasLegendgroup && fullData [ i ] . legendgroup === legendgroup ) ;
195
- setVisibility ( fullData [ i ] , ( isInGroup || notInLegend ) ? true : otherState ) ;
204
+ if ( isInGroup && groupClick === false ) continue ;
205
+ setVisibility ( fullData [ i ] , ( ( isInGroup && toggleGroup ) || notInLegend ) ? true : otherState ) ;
196
206
break ;
197
207
}
198
208
}
@@ -219,7 +229,7 @@ module.exports = function handleClick(g, gd, numClicks) {
219
229
for ( i = 0 ; i < keys . length ; i ++ ) {
220
230
key = keys [ i ] ;
221
231
for ( j = 0 ; j < attrIndices . length ; j ++ ) {
222
- // Use hasOwnPropety to protect against falsey values:
232
+ // Use hasOwnProperty to protect against falsy values:
223
233
if ( ! attrUpdate [ key ] . hasOwnProperty ( j ) ) {
224
234
attrUpdate [ key ] [ j ] = undefined ;
225
235
}
0 commit comments