@@ -142,6 +142,7 @@ describe('Test select box and lasso in general:', function() {
142
142
. map ( function ( v ) { return 'id-' + v ; } ) ;
143
143
mockCopy . data [ 0 ] . customdata = mockCopy . data [ 0 ] . y
144
144
. map ( function ( v ) { return 'customdata-' + v ; } ) ;
145
+ addInvisible ( mockCopy ) ;
145
146
146
147
var gd ;
147
148
beforeEach ( function ( done ) {
@@ -213,6 +214,7 @@ describe('Test select box and lasso in general:', function() {
213
214
describe ( 'lasso events' , function ( ) {
214
215
var mockCopy = Lib . extendDeep ( { } , mock ) ;
215
216
mockCopy . layout . dragmode = 'lasso' ;
217
+ addInvisible ( mockCopy ) ;
216
218
217
219
var gd ;
218
220
beforeEach ( function ( done ) {
@@ -293,6 +295,9 @@ describe('Test select box and lasso in general:', function() {
293
295
} ) ;
294
296
295
297
it ( 'should skip over non-visible traces' , function ( done ) {
298
+ // note: this tests a mock with one or several invisible traces
299
+ // the invisible traces in the other tests test for multiple
300
+ // traces, with some visible and some not.
296
301
var mockCopy = Lib . extendDeep ( { } , mock ) ;
297
302
mockCopy . layout . dragmode = 'select' ;
298
303
@@ -348,6 +353,21 @@ describe('Test select box and lasso in general:', function() {
348
353
. then ( resetAndLasso )
349
354
. then ( function ( ) {
350
355
checkPointCount ( 1 , '(back to lasso case 0)' ) ;
356
+
357
+ mockCopy = Lib . extendDeep ( { } , mock ) ;
358
+ mockCopy . layout . dragmode = 'select' ;
359
+ mockCopy . data [ 0 ] . visible = false ;
360
+ addInvisible ( mockCopy ) ;
361
+ return Plotly . newPlot ( gd , mockCopy ) ;
362
+ } )
363
+ . then ( resetAndSelect )
364
+ . then ( function ( ) {
365
+ checkPointCount ( 0 , '(multiple invisible traces select)' ) ;
366
+ return Plotly . relayout ( gd , 'dragmode' , 'lasso' ) ;
367
+ } )
368
+ . then ( resetAndLasso )
369
+ . then ( function ( ) {
370
+ checkPointCount ( 0 , '(multiple invisible traces lasso)' ) ;
351
371
} )
352
372
. catch ( fail )
353
373
. then ( done ) ;
@@ -502,6 +522,7 @@ describe('Test select box and lasso per trace:', function() {
502
522
var fig = Lib . extendDeep ( { } , require ( '@mocks/ternary_simple' ) ) ;
503
523
fig . layout . width = 800 ;
504
524
fig . layout . dragmode = 'select' ;
525
+ addInvisible ( fig ) ;
505
526
506
527
Plotly . plot ( gd , fig ) . then ( function ( ) {
507
528
return _run (
@@ -545,6 +566,7 @@ describe('Test select box and lasso per trace:', function() {
545
566
546
567
var fig = Lib . extendDeep ( { } , require ( '@mocks/scattercarpet' ) ) ;
547
568
fig . layout . dragmode = 'select' ;
569
+ addInvisible ( fig ) ;
548
570
549
571
Plotly . plot ( gd , fig ) . then ( function ( ) {
550
572
return _run (
@@ -577,6 +599,7 @@ describe('Test select box and lasso per trace:', function() {
577
599
fig . config = {
578
600
mapboxAccessToken : require ( '@build/credentials.json' ) . MAPBOX_ACCESS_TOKEN
579
601
} ;
602
+ addInvisible ( fig ) ;
580
603
581
604
Plotly . plot ( gd , fig ) . then ( function ( ) {
582
605
return _run (
@@ -620,21 +643,26 @@ describe('Test select box and lasso per trace:', function() {
620
643
var assertPoints = makeAssertPoints ( [ 'lon' , 'lat' ] ) ;
621
644
var assertRanges = makeAssertRanges ( 'geo' ) ;
622
645
var assertLassoPoints = makeAssertLassoPoints ( 'geo' ) ;
646
+ var fig = {
647
+ data : [ {
648
+ type : 'scattergeo' ,
649
+ lon : [ 10 , 20 , 30 ] ,
650
+ lat : [ 10 , 20 , 30 ]
651
+ } , {
652
+ type : 'scattergeo' ,
653
+ lon : [ - 10 , - 20 , - 30 ] ,
654
+ lat : [ 10 , 20 , 30 ]
655
+ } ] ,
656
+ layout : {
657
+ showlegend : false ,
658
+ dragmode : 'select' ,
659
+ width : 800 ,
660
+ height : 600
661
+ }
662
+ } ;
663
+ addInvisible ( fig ) ;
623
664
624
- Plotly . plot ( gd , [ {
625
- type : 'scattergeo' ,
626
- lon : [ 10 , 20 , 30 ] ,
627
- lat : [ 10 , 20 , 30 ]
628
- } , {
629
- type : 'scattergeo' ,
630
- lon : [ - 10 , - 20 , - 30 ] ,
631
- lat : [ 10 , 20 , 30 ]
632
- } ] , {
633
- showlegend : false ,
634
- dragmode : 'select' ,
635
- width : 800 ,
636
- height : 600
637
- } )
665
+ Plotly . plot ( gd , fig )
638
666
. then ( function ( ) {
639
667
return _run (
640
668
[ [ 350 , 200 ] , [ 450 , 400 ] ] ,
@@ -686,6 +714,7 @@ describe('Test select box and lasso per trace:', function() {
686
714
fig . layout . height = 450 ;
687
715
fig . layout . dragmode = 'select' ;
688
716
fig . layout . geo . scope = 'europe' ;
717
+ addInvisible ( fig , false ) ;
689
718
690
719
Plotly . plot ( gd , fig )
691
720
. then ( function ( ) {
@@ -735,6 +764,7 @@ describe('Test select box and lasso per trace:', function() {
735
764
736
765
var fig = Lib . extendDeep ( { } , require ( '@mocks/0' ) ) ;
737
766
fig . layout . dragmode = 'lasso' ;
767
+ addInvisible ( fig ) ;
738
768
739
769
Plotly . plot ( gd , fig )
740
770
. then ( function ( ) {
@@ -788,6 +818,7 @@ describe('Test select box and lasso per trace:', function() {
788
818
fig . layout . dragmode = 'lasso' ;
789
819
fig . layout . width = 600 ;
790
820
fig . layout . height = 500 ;
821
+ addInvisible ( fig ) ;
791
822
792
823
Plotly . plot ( gd , fig )
793
824
. then ( function ( ) {
@@ -824,3 +855,16 @@ describe('Test select box and lasso per trace:', function() {
824
855
. then ( done ) ;
825
856
} ) ;
826
857
} ) ;
858
+
859
+ // to make sure none of the above tests fail with extraneous invisible traces,
860
+ // add a bunch of them here
861
+ function addInvisible ( fig , canHaveLegend ) {
862
+ var data = fig . data ;
863
+ var inputData = Lib . extendDeep ( [ ] , data ) ;
864
+ for ( var i = 0 ; i < inputData . length ; i ++ ) {
865
+ data . push ( Lib . extendDeep ( { } , inputData [ i ] , { visible : false } ) ) ;
866
+ if ( canHaveLegend !== false ) data . push ( Lib . extendDeep ( { } , inputData [ i ] , { visible : 'legendonly' } ) ) ;
867
+ }
868
+
869
+ if ( inputData . length === 1 && fig . layout . showlegend !== true ) fig . layout . showlegend = false ;
870
+ }
0 commit comments