@@ -416,7 +416,9 @@ describe('sankey tests', function() {
416
416
[ 'source: Solid' , 'target: Industry' , '46TWh' ] ,
417
417
[ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
418
418
) ;
419
-
419
+ } )
420
+ // Test layout.hoverlabel
421
+ . then ( function ( ) {
420
422
return Plotly . relayout ( gd , 'hoverlabel.font.family' , 'Roboto' ) ;
421
423
} )
422
424
. then ( function ( ) {
@@ -434,16 +436,45 @@ describe('sankey tests', function() {
434
436
[ 'source: Solid' , 'target: Industry' , '46TWh' ] ,
435
437
[ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Roboto' , 'rgb(255, 255, 255)' ]
436
438
) ;
439
+ } )
440
+ // Test trace-level hoverlabel
441
+ . then ( function ( ) {
442
+ return Plotly . restyle ( gd , {
443
+ 'hoverlabel.bgcolor' : 'blue' ,
444
+ 'hoverlabel.bordercolor' : 'red' ,
445
+ 'hoverlabel.font.size' : 22 ,
446
+ 'hoverlabel.font.color' : 'magenta'
447
+ } ) ;
448
+ } )
449
+ . then ( function ( ) {
450
+ _hover ( 404 , 302 ) ;
437
451
452
+ assertLabel (
453
+ [ 'Solid' , 'incoming flow count: 4' , 'outgoing flow count: 3' , '447TWh' ] ,
454
+ [ 'rgb(0, 0, 255)' , 'rgb(255, 0, 0)' , 22 , 'Roboto' , 'rgb(255, 0, 255)' ]
455
+ ) ;
456
+ } )
457
+ . then ( function ( ) {
458
+ _hover ( 450 , 300 ) ;
459
+
460
+ assertLabel (
461
+ [ 'source: Solid' , 'target: Industry' , '46TWh' ] ,
462
+ [ 'rgb(0, 0, 255)' , 'rgb(255, 0, 0)' , 22 , 'Roboto' , 'rgb(255, 0, 255)' ]
463
+ ) ;
464
+ } )
465
+ // Test (node|link).hoverlabel
466
+ . then ( function ( ) {
438
467
return Plotly . restyle ( gd , {
439
468
'node.hoverlabel.bgcolor' : 'red' ,
440
469
'node.hoverlabel.bordercolor' : 'blue' ,
441
470
'node.hoverlabel.font.size' : 20 ,
442
471
'node.hoverlabel.font.color' : 'black' ,
472
+ 'node.hoverlabel.font.family' : 'Roboto' ,
443
473
'link.hoverlabel.bgcolor' : 'yellow' ,
444
474
'link.hoverlabel.bordercolor' : 'magenta' ,
445
475
'link.hoverlabel.font.size' : 18 ,
446
- 'link.hoverlabel.font.color' : 'green'
476
+ 'link.hoverlabel.font.color' : 'green' ,
477
+ 'link.hoverlabel.font.family' : 'Roboto'
447
478
} ) ;
448
479
} )
449
480
. then ( function ( ) {
@@ -556,49 +587,59 @@ describe('sankey tests', function() {
556
587
. then ( done ) ;
557
588
} ) ;
558
589
559
- it ( 'should not show node labels if node.hoverinfo is none' , function ( done ) {
560
- var gd = createGraphDiv ( ) ;
561
- var mockCopy = Lib . extendDeep ( { } , mock ) ;
590
+ [ 'skip' , 'none' ] . forEach ( function ( hoverinfoFlag ) {
591
+ it ( 'should not show node labels if node.hoverinfo is ' + hoverinfoFlag , function ( done ) {
592
+ var gd = createGraphDiv ( ) ;
593
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
562
594
563
- Plotly . plot ( gd , mockCopy ) . then ( function ( ) {
564
- return Plotly . restyle ( gd , 'node.hoverinfo' , 'none' ) ;
565
- } )
566
- . then ( function ( ) {
567
- _hover ( node [ 0 ] , node [ 1 ] ) ;
568
- assertNoLabel ( ) ;
569
- } )
570
- . catch ( failTest )
571
- . then ( done ) ;
595
+ Plotly . plot ( gd , mockCopy ) . then ( function ( ) {
596
+ return Plotly . restyle ( gd , 'node.hoverinfo' , hoverinfoFlag ) ;
597
+ } )
598
+ . then ( function ( ) {
599
+ _hover ( node [ 0 ] , node [ 1 ] ) ;
600
+ assertNoLabel ( ) ;
601
+ } )
602
+ . catch ( failTest )
603
+ . then ( done ) ;
604
+ } ) ;
572
605
} ) ;
573
606
574
- it ( 'should not show link labels if link.hoverinfo is none' , function ( done ) {
575
- var gd = createGraphDiv ( ) ;
576
- var mockCopy = Lib . extendDeep ( { } , mock ) ;
607
+ [ 'skip' , 'none' ] . forEach ( function ( hoverinfoFlag ) {
608
+ it ( 'should not show link labels if link.hoverinfo is ' + hoverinfoFlag , function ( done ) {
609
+ var gd = createGraphDiv ( ) ;
610
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
577
611
578
- Plotly . plot ( gd , mockCopy ) . then ( function ( ) {
579
- return Plotly . restyle ( gd , 'link.hoverinfo' , 'none' ) ;
580
- } )
581
- . then ( function ( ) {
582
- _hover ( link [ 0 ] , link [ 1 ] ) ;
583
- assertNoLabel ( ) ;
584
- } )
585
- . catch ( failTest )
586
- . then ( done ) ;
612
+ Plotly . plot ( gd , mockCopy ) . then ( function ( ) {
613
+ return Plotly . restyle ( gd , 'link.hoverinfo' , hoverinfoFlag ) ;
614
+ } )
615
+ . then ( function ( ) {
616
+ _hover ( link [ 0 ] , link [ 1 ] ) ;
617
+ assertNoLabel ( ) ;
618
+ } )
619
+ . catch ( failTest )
620
+ . then ( done ) ;
621
+ } ) ;
587
622
} ) ;
588
623
589
- it ( 'should not show node labels if node.hoverinfo is skip' , function ( done ) {
590
- var gd = createGraphDiv ( ) ;
591
- var mockCopy = Lib . extendDeep ( { } , mock ) ;
624
+ [ 'skip' , 'none' ] . forEach ( function ( hoverinfoFlag ) {
625
+ it ( 'should not show labels if trace hoverinfo is ' + hoverinfoFlag + ' and (node|link).hoverinfo is undefined' , function ( done ) {
626
+ var gd = createGraphDiv ( ) ;
627
+ var mockCopy = Lib . extendDeep ( { } , mock ) ;
592
628
593
- Plotly . plot ( gd , mockCopy ) . then ( function ( ) {
594
- return Plotly . restyle ( gd , 'node.hoverinfo' , 'skip' ) ;
595
- } )
596
- . then ( function ( ) {
597
- _hover ( node [ 0 ] , node [ 1 ] ) ;
598
- assertNoLabel ( ) ;
599
- } )
600
- . catch ( failTest )
601
- . then ( done ) ;
629
+ Plotly . plot ( gd , mockCopy ) . then ( function ( ) {
630
+ return Plotly . restyle ( gd , 'hoverinfo' , hoverinfoFlag ) ;
631
+ } )
632
+ . then ( function ( ) {
633
+ _hover ( node [ 0 ] , node [ 1 ] ) ;
634
+ assertNoLabel ( ) ;
635
+ } )
636
+ . then ( function ( ) {
637
+ _hover ( link [ 0 ] , link [ 1 ] ) ;
638
+ assertNoLabel ( ) ;
639
+ } )
640
+ . catch ( failTest )
641
+ . then ( done ) ;
642
+ } ) ;
602
643
} ) ;
603
644
604
645
it ( 'should not show link labels if link.hoverinfo is skip' , function ( done ) {
@@ -748,7 +789,7 @@ describe('sankey tests', function() {
748
789
} ;
749
790
}
750
791
751
- it ( 'should not output hover/unhover event data when hovermoder is false' , function ( done ) {
792
+ it ( 'should not output hover/unhover event data when hovermode is false' , function ( done ) {
752
793
var fig = Lib . extendDeep ( { } , mock ) ;
753
794
754
795
Plotly . plot ( gd , fig )
@@ -759,17 +800,28 @@ describe('sankey tests', function() {
759
800
. then ( done ) ;
760
801
} ) ;
761
802
762
- it ( 'should not output hover/unhover event data when hoverinfo is skip' , function ( done ) {
803
+ it ( 'should not output hover/unhover event data when trace hoverinfo is skip' , function ( done ) {
763
804
var fig = Lib . extendDeep ( { } , mock ) ;
764
805
765
806
Plotly . plot ( gd , fig )
766
- . then ( function ( ) { return Plotly . restyle ( gd , 'link. hoverinfo' , 'skip' ) ; } )
807
+ . then ( function ( ) { return Plotly . restyle ( gd , 'hoverinfo' , 'skip' ) ; } )
767
808
. then ( assertNoHoverEvents ( 'link' ) )
768
- . then ( function ( ) { return Plotly . restyle ( gd , 'node.hoverinfo' , 'skip' ) ; } )
769
809
. then ( assertNoHoverEvents ( 'node' ) )
770
810
. catch ( failTest )
771
811
. then ( done ) ;
772
812
} ) ;
813
+
814
+ [ 'node' , 'link' ] . forEach ( function ( obj ) {
815
+ it ( 'should not output hover/unhover event data when ' + obj + '.hoverinfo is skip' , function ( done ) {
816
+ var fig = Lib . extendDeep ( { } , mock ) ;
817
+
818
+ Plotly . plot ( gd , fig )
819
+ . then ( function ( ) { return Plotly . restyle ( gd , obj + '.hoverinfo' , 'skip' ) ; } )
820
+ . then ( assertNoHoverEvents ( obj ) )
821
+ . catch ( failTest )
822
+ . then ( done ) ;
823
+ } ) ;
824
+ } ) ;
773
825
} ) ;
774
826
775
827
it ( 'emits a warning if node.pad is too large' , function ( done ) {
0 commit comments