@@ -1034,14 +1034,18 @@ describe('Test hover label custom styling:', function() {
10341034 function assertLabel ( className , expectation ) {
10351035 var g = d3 . select ( 'g.' + className ) ;
10361036
1037- var path = g . select ( 'path' ) ;
1038- expect ( path . style ( 'fill' ) ) . toEqual ( expectation . path [ 0 ] , 'bgcolor' ) ;
1039- expect ( path . style ( 'stroke' ) ) . toEqual ( expectation . path [ 1 ] , 'bordercolor' ) ;
1040-
1041- var text = g . select ( { hovertext : 'text.nums' , axistext : 'text' } [ className ] ) ;
1042- expect ( parseInt ( text . style ( 'font-size' ) ) ) . toEqual ( expectation . text [ 0 ] , 'font.size' ) ;
1043- expect ( text . style ( 'font-family' ) . split ( ',' ) [ 0 ] ) . toEqual ( expectation . text [ 1 ] , 'font.family' ) ;
1044- expect ( text . style ( 'fill' ) ) . toEqual ( expectation . text [ 2 ] , 'font.color' ) ;
1037+ if ( expectation === null ) {
1038+ expect ( g . size ( ) ) . toBe ( 0 ) ;
1039+ } else {
1040+ var path = g . select ( 'path' ) ;
1041+ expect ( path . style ( 'fill' ) ) . toEqual ( expectation . path [ 0 ] , 'bgcolor' ) ;
1042+ expect ( path . style ( 'stroke' ) ) . toEqual ( expectation . path [ 1 ] , 'bordercolor' ) ;
1043+
1044+ var text = g . select ( { hovertext : 'text.nums' , axistext : 'text' } [ className ] ) ;
1045+ expect ( parseInt ( text . style ( 'font-size' ) ) ) . toEqual ( expectation . text [ 0 ] , 'font.size' ) ;
1046+ expect ( text . style ( 'font-family' ) . split ( ',' ) [ 0 ] ) . toEqual ( expectation . text [ 1 ] , 'font.family' ) ;
1047+ expect ( text . style ( 'fill' ) ) . toEqual ( expectation . text [ 2 ] , 'font.color' ) ;
1048+ }
10451049 }
10461050
10471051 function assertPtLabel ( expectation ) {
@@ -1112,8 +1116,40 @@ describe('Test hover label custom styling:', function() {
11121116 text : [ 13 , 'Arial' , 'rgb(255, 255, 255)' ]
11131117 } ) ;
11141118
1119+ // test arrayOk case
1120+ return Plotly . restyle ( gd , 'hoverinfo' , [ [ 'skip' , 'name' , 'x' ] ] ) ;
1121+ } )
1122+ . then ( function ( ) {
1123+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 0 ] } ) ;
1124+
1125+ assertPtLabel ( null ) ;
1126+ assertCommonLabel ( null ) ;
1127+ } )
1128+ . then ( function ( ) {
1129+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 1 ] } ) ;
1130+
1131+ assertPtLabel ( {
1132+ path : [ 'rgb(255, 255, 255)' , 'rgb(68, 68, 68)' ] ,
1133+ text : [ 20 , 'Arial' , 'rgb(0, 128, 0)' ]
1134+ } ) ;
1135+ assertCommonLabel ( null ) ;
1136+ } )
1137+ . then ( function ( ) {
1138+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 2 ] } ) ;
1139+
1140+ assertPtLabel ( null ) ;
1141+ assertCommonLabel ( {
1142+ path : [ 'rgb(255, 255, 255)' , 'rgb(255, 255, 255)' ] ,
1143+ text : [ 13 , 'Arial' , 'rgb(255, 255, 255)' ]
1144+ } ) ;
1145+
11151146 // test base case
1116- return Plotly . update ( gd , { hoverlabel : null } , { hoverlabel : null } ) ;
1147+ return Plotly . update ( gd , {
1148+ hoverlabel : null ,
1149+ hoverinfo : null
1150+ } , {
1151+ hoverlabel : null
1152+ } ) ;
11171153 } )
11181154 . then ( function ( ) {
11191155 _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 0 ] } ) ;
0 commit comments