@@ -342,8 +342,7 @@ describe('ModeBar', function() {
342
342
var buttons = getButtons ( [
343
343
[ 'toImage' ] ,
344
344
[ 'zoom2d' , 'pan2d' ] ,
345
- [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
346
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
345
+ [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ]
347
346
] ) ;
348
347
349
348
var gd = getMockGraphInfo ( [ 'x' ] , [ 'y' ] ) ;
@@ -361,8 +360,7 @@ describe('ModeBar', function() {
361
360
var buttons = getButtons ( [
362
361
[ 'toImage' ] ,
363
362
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
364
- [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
365
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
363
+ [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ]
366
364
] ) ;
367
365
368
366
var gd = getMockGraphInfo ( [ 'x' ] , [ 'y' ] ) ;
@@ -385,8 +383,7 @@ describe('ModeBar', function() {
385
383
var buttons = getButtons ( [
386
384
[ 'toImage' ] ,
387
385
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
388
- [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
389
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
386
+ [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ]
390
387
] ) ;
391
388
392
389
var gd = getMockGraphInfo ( [ 'x' ] , [ 'y' ] ) ;
@@ -407,8 +404,7 @@ describe('ModeBar', function() {
407
404
408
405
it ( 'creates mode bar (cartesian fixed-axes version)' , function ( ) {
409
406
var buttons = getButtons ( [
410
- [ 'toImage' ] ,
411
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
407
+ [ 'toImage' ]
412
408
] ) ;
413
409
414
410
var gd = getMockGraphInfo ( ) ;
@@ -425,8 +421,7 @@ describe('ModeBar', function() {
425
421
var buttons = getButtons ( [
426
422
[ 'toImage' ] ,
427
423
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
428
- [ 'resetCameraDefault3d' , 'resetCameraLastSave3d' ] ,
429
- [ 'hoverClosest3d' ]
424
+ [ 'resetCameraDefault3d' , 'resetCameraLastSave3d' ]
430
425
] ) ;
431
426
432
427
var gd = getMockGraphInfo ( ) ;
@@ -443,8 +438,7 @@ describe('ModeBar', function() {
443
438
var buttons = getButtons ( [
444
439
[ 'toImage' ] ,
445
440
[ 'pan2d' ] ,
446
- [ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ] ,
447
- [ 'hoverClosestGeo' ]
441
+ [ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ]
448
442
] ) ;
449
443
450
444
var gd = getMockGraphInfo ( ) ;
@@ -461,8 +455,7 @@ describe('ModeBar', function() {
461
455
var buttons = getButtons ( [
462
456
[ 'toImage' ] ,
463
457
[ 'pan2d' , 'select2d' , 'lasso2d' ] ,
464
- [ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ] ,
465
- [ 'hoverClosestGeo' ]
458
+ [ 'zoomInGeo' , 'zoomOutGeo' , 'resetGeo' ]
466
459
] ) ;
467
460
468
461
var gd = getMockGraphInfo ( ) ;
@@ -484,8 +477,7 @@ describe('ModeBar', function() {
484
477
var buttons = getButtons ( [
485
478
[ 'toImage' ] ,
486
479
[ 'pan2d' ] ,
487
- [ 'zoomInMapbox' , 'zoomOutMapbox' , 'resetViewMapbox' ] ,
488
- [ 'toggleHover' ]
480
+ [ 'zoomInMapbox' , 'zoomOutMapbox' , 'resetViewMapbox' ]
489
481
] ) ;
490
482
491
483
var gd = getMockGraphInfo ( ) ;
@@ -502,8 +494,7 @@ describe('ModeBar', function() {
502
494
var buttons = getButtons ( [
503
495
[ 'toImage' ] ,
504
496
[ 'pan2d' , 'select2d' , 'lasso2d' ] ,
505
- [ 'zoomInMapbox' , 'zoomOutMapbox' , 'resetViewMapbox' ] ,
506
- [ 'toggleHover' ]
497
+ [ 'zoomInMapbox' , 'zoomOutMapbox' , 'resetViewMapbox' ]
507
498
] ) ;
508
499
509
500
var gd = getMockGraphInfo ( ) ;
@@ -525,8 +516,7 @@ describe('ModeBar', function() {
525
516
var buttons = getButtons ( [
526
517
[ 'toImage' ] ,
527
518
[ 'zoom2d' , 'pan2d' ] ,
528
- [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
529
- [ 'hoverClosestGl2d' ]
519
+ [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ]
530
520
] ) ;
531
521
532
522
var gd = getMockGraphInfo ( [ 'x' ] , [ 'y' ] ) ;
@@ -542,8 +532,7 @@ describe('ModeBar', function() {
542
532
543
533
it ( 'creates mode bar (pie version)' , function ( ) {
544
534
var buttons = getButtons ( [
545
- [ 'toImage' ] ,
546
- [ 'hoverClosestPie' ]
535
+ [ 'toImage' ]
547
536
] ) ;
548
537
549
538
var gd = getMockGraphInfo ( ) ;
@@ -560,8 +549,7 @@ describe('ModeBar', function() {
560
549
var buttons = getButtons ( [
561
550
[ 'toImage' ] ,
562
551
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
563
- [ 'resetViews' ] ,
564
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
552
+ [ 'resetViews' ]
565
553
] ) ;
566
554
567
555
var gd = getMockGraphInfo ( ) ;
@@ -578,8 +566,7 @@ describe('ModeBar', function() {
578
566
var buttons = getButtons ( [
579
567
[ 'toImage' ] ,
580
568
[ 'zoom2d' , 'pan2d' ] ,
581
- [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ] ,
582
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
569
+ [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ]
583
570
] ) ;
584
571
585
572
var gd = getMockGraphInfo ( [ 'x' ] , [ 'y' ] ) ;
@@ -597,8 +584,7 @@ describe('ModeBar', function() {
597
584
var buttons = getButtons ( [
598
585
[ 'toImage' ] ,
599
586
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
600
- [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ] ,
601
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
587
+ [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetViews' ]
602
588
] ) ;
603
589
604
590
var gd = getMockGraphInfo ( [ 'x' ] , [ 'y' ] ) ;
@@ -621,8 +607,7 @@ describe('ModeBar', function() {
621
607
var buttons = getButtons ( [
622
608
[ 'toImage' ] ,
623
609
[ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
624
- [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ] ,
625
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
610
+ [ 'zoomIn2d' , 'zoomOut2d' , 'autoScale2d' , 'resetScale2d' ]
626
611
] ) ;
627
612
628
613
var gd = getMockGraphInfo ( [ 'x' ] , [ 'y' ] ) ;
@@ -645,8 +630,7 @@ describe('ModeBar', function() {
645
630
var buttons = getButtons ( [
646
631
[ 'toImage' ] ,
647
632
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
648
- [ 'resetViews' ] ,
649
- [ 'toggleHover' ]
633
+ [ 'resetViews' ]
650
634
] ) ;
651
635
652
636
var gd = getMockGraphInfo ( ) ;
@@ -662,8 +646,7 @@ describe('ModeBar', function() {
662
646
it ( 'creates mode bar (un-selectable ternary version)' , function ( ) {
663
647
var buttons = getButtons ( [
664
648
[ 'toImage' ] ,
665
- [ 'zoom2d' , 'pan2d' ] ,
666
- [ 'toggleHover' ]
649
+ [ 'zoom2d' , 'pan2d' ]
667
650
] ) ;
668
651
669
652
var gd = getMockGraphInfo ( ) ;
@@ -679,8 +662,7 @@ describe('ModeBar', function() {
679
662
it ( 'creates mode bar (selectable ternary version)' , function ( ) {
680
663
var buttons = getButtons ( [
681
664
[ 'toImage' ] ,
682
- [ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ] ,
683
- [ 'toggleHover' ]
665
+ [ 'zoom2d' , 'pan2d' , 'select2d' , 'lasso2d' ]
684
666
] ) ;
685
667
686
668
var gd = getMockGraphInfo ( ) ;
@@ -701,8 +683,7 @@ describe('ModeBar', function() {
701
683
it ( 'creates mode bar (ternary + cartesian version)' , function ( ) {
702
684
var buttons = getButtons ( [
703
685
[ 'toImage' ] ,
704
- [ 'zoom2d' , 'pan2d' ] ,
705
- [ 'toggleSpikelines' , 'hoverClosestCartesian' , 'hoverCompareCartesian' ]
686
+ [ 'zoom2d' , 'pan2d' ]
706
687
] ) ;
707
688
708
689
var gd = getMockGraphInfo ( ) ;
@@ -719,8 +700,7 @@ describe('ModeBar', function() {
719
700
var buttons = getButtons ( [
720
701
[ 'toImage' ] ,
721
702
[ 'zoom3d' , 'pan3d' , 'orbitRotation' , 'tableRotation' ] ,
722
- [ 'resetViews' ] ,
723
- [ 'toggleHover' ]
703
+ [ 'resetViews' ]
724
704
] ) ;
725
705
726
706
var gd = getMockGraphInfo ( ) ;
@@ -733,36 +713,6 @@ describe('ModeBar', function() {
733
713
checkButtons ( modeBar , buttons , 1 ) ;
734
714
} ) ;
735
715
736
- it ( 'creates mode bar without hover button when all traces are noHover' , function ( ) {
737
- var buttons = getButtons ( [
738
- [ 'toImage' ]
739
- ] ) ;
740
-
741
- var gd = getMockGraphInfo ( ) ;
742
- gd . _fullData = [ { type : 'indicator' } ] ;
743
-
744
- manageModeBar ( gd ) ;
745
- var modeBar = gd . _fullLayout . _modeBar ;
746
-
747
- checkButtons ( modeBar , buttons , 1 ) ;
748
- } ) ;
749
-
750
- it ( 'creates mode bar with hover button even in the presence of one noHover trace' , function ( ) {
751
- var buttons = getButtons ( [
752
- [ 'toImage' ] ,
753
- [ 'hoverClosestPie' ]
754
- ] ) ;
755
-
756
- var gd = getMockGraphInfo ( ) ;
757
- gd . _fullLayout . _basePlotModules = [ { name : 'pie' } ] ;
758
- gd . _fullData = [ { type : 'indicator' } , { type : 'pie' } ] ;
759
-
760
- manageModeBar ( gd ) ;
761
- var modeBar = gd . _fullLayout . _modeBar ;
762
-
763
- checkButtons ( modeBar , buttons , 1 ) ;
764
- } ) ;
765
-
766
716
it ( 'throws an error if modeBarButtonsToRemove isn\'t an array' , function ( ) {
767
717
var gd = getMockGraphInfo ( ) ;
768
718
gd . _context . modeBarButtonsToRemove = 'not gonna work' ;
@@ -811,32 +761,28 @@ describe('ModeBar', function() {
811
761
gd . _fullData = [ { type : 'pie' } ] ;
812
762
manageModeBar ( gd ) ;
813
763
checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
814
- [ 'toImage' ] ,
815
- [ 'hoverClosestPie' ]
764
+ [ 'toImage' ]
816
765
] ) , 1 ) ;
817
766
818
767
gd . _context . showSendToCloud = true ;
819
768
gd . _context . showEditInChartStudio = false ;
820
769
manageModeBar ( gd ) ;
821
770
checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
822
- [ 'toImage' , 'sendDataToCloud' ] ,
823
- [ 'hoverClosestPie' ]
771
+ [ 'toImage' , 'sendDataToCloud' ]
824
772
] ) , 1 ) ;
825
773
826
774
gd . _context . showSendToCloud = false ;
827
775
gd . _context . showEditInChartStudio = true ;
828
776
manageModeBar ( gd ) ;
829
777
checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
830
- [ 'toImage' , 'editInChartStudio' ] ,
831
- [ 'hoverClosestPie' ]
778
+ [ 'toImage' , 'editInChartStudio' ]
832
779
] ) , 1 ) ;
833
780
834
781
gd . _context . showSendToCloud = true ;
835
782
gd . _context . showEditInChartStudio = true ;
836
783
manageModeBar ( gd ) ;
837
784
checkButtons ( gd . _fullLayout . _modeBar , getButtons ( [
838
- [ 'toImage' , 'editInChartStudio' ] ,
839
- [ 'hoverClosestPie' ]
785
+ [ 'toImage' , 'editInChartStudio' ]
840
786
] ) , 1 ) ;
841
787
} ) ;
842
788
@@ -863,13 +809,13 @@ describe('ModeBar', function() {
863
809
var gd = setupGraphInfo ( ) ;
864
810
manageModeBar ( gd ) ;
865
811
866
- expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 11 ) ;
812
+ expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 8 ) ;
867
813
868
- gd . _fullLayout . _basePlotModules = [ { name : 'gl3d ' } ] ;
869
- gd . _fullData = [ { type : 'scatter3d ' } ] ;
814
+ gd . _fullLayout . _basePlotModules = [ { name : 'geo ' } ] ;
815
+ gd . _fullData = [ { type : 'scattergeo ' } ] ;
870
816
manageModeBar ( gd ) ;
871
817
872
- expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 9 ) ;
818
+ expect ( countButtons ( gd . _fullLayout . _modeBar ) ) . toEqual ( 6 ) ;
873
819
} ) ;
874
820
875
821
it ( 'updates mode bar buttons if modeBarButtonsToRemove changes' , function ( ) {
@@ -906,7 +852,7 @@ describe('ModeBar', function() {
906
852
it ( 'sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove' , function ( ) {
907
853
var gd = setupGraphInfo ( ) ;
908
854
gd . _context . modeBarButtonsToRemove = [
909
- 'toImage' , 'pan2d' , 'hoverCompareCartesian'
855
+ 'toImage' , 'pan2d'
910
856
] ;
911
857
gd . _context . modeBarButtonsToAdd = [
912
858
{ name : 'some button' , click : noop } ,
@@ -916,14 +862,14 @@ describe('ModeBar', function() {
916
862
manageModeBar ( gd ) ;
917
863
918
864
var modeBar = gd . _fullLayout . _modeBar ;
919
- expect ( countGroups ( modeBar ) ) . toEqual ( 6 ) ;
920
- expect ( countButtons ( modeBar ) ) . toEqual ( 10 ) ;
865
+ expect ( countGroups ( modeBar ) ) . toEqual ( 5 ) ;
866
+ expect ( countButtons ( modeBar ) ) . toEqual ( 8 ) ;
921
867
} ) ;
922
868
923
869
it ( 'sets up buttons with modeBarButtonsToAdd and modeBarButtonToRemove (2)' , function ( ) {
924
870
var gd = setupGraphInfo ( ) ;
925
871
gd . _context . modeBarButtonsToRemove = [
926
- 'toImage' , 'pan2d' , 'hoverCompareCartesian'
872
+ 'toImage' , 'pan2d'
927
873
] ;
928
874
gd . _context . modeBarButtonsToAdd = [ [
929
875
{ name : 'some button' , click : noop } ,
@@ -936,8 +882,8 @@ describe('ModeBar', function() {
936
882
manageModeBar ( gd ) ;
937
883
938
884
var modeBar = gd . _fullLayout . _modeBar ;
939
- expect ( countGroups ( modeBar ) ) . toEqual ( 7 ) ;
940
- expect ( countButtons ( modeBar ) ) . toEqual ( 12 ) ;
885
+ expect ( countGroups ( modeBar ) ) . toEqual ( 6 ) ;
886
+ expect ( countButtons ( modeBar ) ) . toEqual ( 10 ) ;
941
887
} ) ;
942
888
943
889
it ( 'sets up buttons with fully custom modeBarButtons' , function ( ) {
@@ -1119,7 +1065,13 @@ describe('ModeBar', function() {
1119
1065
} ;
1120
1066
1121
1067
gd = createGraphDiv ( ) ;
1122
- Plotly . newPlot ( gd , mockData , mockLayout ) . then ( function ( ) {
1068
+ Plotly . newPlot ( gd , mockData , mockLayout , {
1069
+ modeBarButtonsToAdd : [
1070
+ 'toggleSpikelines' ,
1071
+ 'hoverCompareCartesian' ,
1072
+ 'hoverClosestCartesian'
1073
+ ]
1074
+ } ) . then ( function ( ) {
1123
1075
modeBar = gd . _fullLayout . _modeBar ;
1124
1076
buttonToggle = selectButton ( modeBar , 'toggleSpikelines' ) ;
1125
1077
buttonCompare = selectButton ( modeBar , 'hoverCompareCartesian' ) ;
@@ -1197,7 +1149,7 @@ describe('ModeBar', function() {
1197
1149
} ) ;
1198
1150
} ) ;
1199
1151
1200
- describe ( 'buttons hoverCompareCartesian and hoverClosestCartesian ' , function ( ) {
1152
+ describe ( 'buttons hoverCompareCartesian and hoverClosestCartesian' , function ( ) {
1201
1153
it ( 'should update layout hovermode' , function ( ) {
1202
1154
expect ( gd . _fullLayout . hovermode ) . toBe ( 'closest' ) ;
1203
1155
assertActive ( hovermodeButtons , buttonClosest ) ;
@@ -1293,7 +1245,9 @@ describe('ModeBar', function() {
1293
1245
} ] ;
1294
1246
1295
1247
gd = createGraphDiv ( ) ;
1296
- Plotly . newPlot ( gd , mockData ) . then ( function ( ) {
1248
+ Plotly . newPlot ( gd , mockData , { } , {
1249
+ modeBarButtonsToAdd : [ 'hoverClosestPie' ]
1250
+ } ) . then ( function ( ) {
1297
1251
modeBar = gd . _fullLayout . _modeBar ;
1298
1252
done ( ) ;
1299
1253
} ) ;
@@ -1326,7 +1280,9 @@ describe('ModeBar', function() {
1326
1280
} ] ;
1327
1281
1328
1282
gd = createGraphDiv ( ) ;
1329
- Plotly . newPlot ( gd , mockData ) . then ( function ( ) {
1283
+ Plotly . newPlot ( gd , mockData , { } , {
1284
+ modeBarButtonsToAdd : [ 'hoverClosestGeo' ]
1285
+ } ) . then ( function ( ) {
1330
1286
modeBar = gd . _fullLayout . _modeBar ;
1331
1287
done ( ) ;
1332
1288
} ) ;
@@ -1410,7 +1366,9 @@ describe('ModeBar', function() {
1410
1366
1411
1367
Plotly . newPlot ( gd , [
1412
1368
{ type : 'scatterternary' , a : [ 1 ] , b : [ 2 ] , c : [ 3 ] }
1413
- ] )
1369
+ ] , { } , {
1370
+ modeBarButtonsToAdd : [ 'toggleHover' ]
1371
+ } )
1414
1372
. then ( function ( ) {
1415
1373
_run ( 'base' ) ;
1416
1374
0 commit comments