@@ -416,7 +416,9 @@ describe('sankey tests', function() {
416416 [ 'source: Solid' , 'target: Industry' , '46TWh' ] ,
417417 [ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
418418 ) ;
419-
419+ } )
420+ // Test layout.hoverlabel
421+ . then ( function ( ) {
420422 return Plotly . relayout ( gd , 'hoverlabel.font.family' , 'Roboto' ) ;
421423 } )
422424 . then ( function ( ) {
@@ -434,16 +436,45 @@ describe('sankey tests', function() {
434436 [ 'source: Solid' , 'target: Industry' , '46TWh' ] ,
435437 [ 'rgb(0, 0, 96)' , 'rgb(255, 255, 255)' , 13 , 'Roboto' , 'rgb(255, 255, 255)' ]
436438 ) ;
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 ) ;
437451
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 ( ) {
438467 return Plotly . restyle ( gd , {
439468 'node.hoverlabel.bgcolor' : 'red' ,
440469 'node.hoverlabel.bordercolor' : 'blue' ,
441470 'node.hoverlabel.font.size' : 20 ,
442471 'node.hoverlabel.font.color' : 'black' ,
472+ 'node.hoverlabel.font.family' : 'Roboto' ,
443473 'link.hoverlabel.bgcolor' : 'yellow' ,
444474 'link.hoverlabel.bordercolor' : 'magenta' ,
445475 'link.hoverlabel.font.size' : 18 ,
446- 'link.hoverlabel.font.color' : 'green'
476+ 'link.hoverlabel.font.color' : 'green' ,
477+ 'link.hoverlabel.font.family' : 'Roboto'
447478 } ) ;
448479 } )
449480 . then ( function ( ) {
@@ -556,49 +587,59 @@ describe('sankey tests', function() {
556587 . then ( done ) ;
557588 } ) ;
558589
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 ) ;
562594
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+ } ) ;
572605 } ) ;
573606
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 ) ;
577611
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+ } ) ;
587622 } ) ;
588623
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 ) ;
592628
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+ } ) ;
602643 } ) ;
603644
604645 it ( 'should not show link labels if link.hoverinfo is skip' , function ( done ) {
@@ -748,7 +789,7 @@ describe('sankey tests', function() {
748789 } ;
749790 }
750791
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 ) {
752793 var fig = Lib . extendDeep ( { } , mock ) ;
753794
754795 Plotly . plot ( gd , fig )
@@ -759,17 +800,28 @@ describe('sankey tests', function() {
759800 . then ( done ) ;
760801 } ) ;
761802
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 ) {
763804 var fig = Lib . extendDeep ( { } , mock ) ;
764805
765806 Plotly . plot ( gd , fig )
766- . then ( function ( ) { return Plotly . restyle ( gd , 'link. hoverinfo' , 'skip' ) ; } )
807+ . then ( function ( ) { return Plotly . restyle ( gd , 'hoverinfo' , 'skip' ) ; } )
767808 . then ( assertNoHoverEvents ( 'link' ) )
768- . then ( function ( ) { return Plotly . restyle ( gd , 'node.hoverinfo' , 'skip' ) ; } )
769809 . then ( assertNoHoverEvents ( 'node' ) )
770810 . catch ( failTest )
771811 . then ( done ) ;
772812 } ) ;
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+ } ) ;
773825 } ) ;
774826
775827 it ( 'emits a warning if node.pad is too large' , function ( done ) {
0 commit comments