@@ -286,4 +286,51 @@ describe('select box and lasso', function() {
286
286
} ) ;
287
287
} ) ;
288
288
} ) ;
289
+
290
+ it ( 'should skip over non-visible traces' , function ( done ) {
291
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
292
+ mockCopy . layout . dragmode = 'select' ;
293
+
294
+ var selectPath = [ [ 100 , 200 ] , [ 150 , 200 ] ] ;
295
+ var lassoPath = [ [ 331 , 178 ] , [ 333 , 246 ] , [ 350 , 250 ] , [ 343 , 176 ] ] ;
296
+
297
+ var gd = createGraphDiv ( ) ;
298
+ var selectedPtLength ;
299
+
300
+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( function ( ) {
301
+ gd . on ( 'plotly_selected' , function ( data ) {
302
+ selectedPtLength = data . points . length ;
303
+ } ) ;
304
+
305
+ drag ( selectPath ) ;
306
+ expect ( selectedPtLength ) . toEqual ( 2 , '(case 0)' ) ;
307
+
308
+ return Plotly . restyle ( gd , 'visible' , 'legendonly' ) ;
309
+ } ) . then ( function ( ) {
310
+ drag ( selectPath ) ;
311
+ expect ( selectedPtLength ) . toEqual ( 0 , '(legendonly case)' ) ;
312
+
313
+ return Plotly . restyle ( gd , 'visible' , true ) ;
314
+ } ) . then ( function ( ) {
315
+ drag ( selectPath ) ;
316
+ expect ( selectedPtLength ) . toEqual ( 2 , '(back to case 0)' ) ;
317
+
318
+ return Plotly . relayout ( gd , 'dragmode' , 'lasso' ) ;
319
+ } ) . then ( function ( ) {
320
+ drag ( lassoPath ) ;
321
+ expect ( selectedPtLength ) . toEqual ( 1 , '(case 0 lasso)' ) ;
322
+
323
+ return Plotly . restyle ( gd , 'visible' , 'legendonly' ) ;
324
+ } ) . then ( function ( ) {
325
+ drag ( lassoPath ) ;
326
+ expect ( selectedPtLength ) . toEqual ( 0 , '(lasso legendonly case)' ) ;
327
+
328
+ return Plotly . restyle ( gd , 'visible' , true ) ;
329
+ } ) . then ( function ( ) {
330
+ drag ( lassoPath ) ;
331
+ expect ( selectedPtLength ) . toEqual ( 1 , '(back to lasso case 0)' ) ;
332
+
333
+ done ( ) ;
334
+ } ) ;
335
+ } ) ;
289
336
} ) ;
0 commit comments