@@ -2062,7 +2062,7 @@ describe('Test hover label custom styling:', function() {
20622062 } ) ;
20632063 assertCommonLabel ( {
20642064 path : [ 'rgb(255, 255, 255)' , 'rgb(68, 68, 68)' ] ,
2065- text : [ 13 , 'Arial' , 'rgb(255, 255, 255 )' ]
2065+ text : [ 13 , 'Arial' , 'rgb(68, 68, 68 )' ]
20662066 } ) ;
20672067 } )
20682068 . then ( function ( ) {
@@ -2074,7 +2074,7 @@ describe('Test hover label custom styling:', function() {
20742074 } ) ;
20752075 assertCommonLabel ( {
20762076 path : [ 'rgb(255, 255, 255)' , 'rgb(68, 68, 68)' ] ,
2077- text : [ 13 , 'Arial' , 'rgb(255, 255, 255 )' ]
2077+ text : [ 13 , 'Arial' , 'rgb(68, 68, 68 )' ]
20782078 } ) ;
20792079 } )
20802080 . then ( function ( ) {
@@ -2086,7 +2086,7 @@ describe('Test hover label custom styling:', function() {
20862086 } ) ;
20872087 assertCommonLabel ( {
20882088 path : [ 'rgb(255, 255, 255)' , 'rgb(68, 68, 68)' ] ,
2089- text : [ 13 , 'Arial' , 'rgb(255, 255, 255 )' ]
2089+ text : [ 13 , 'Arial' , 'rgb(68, 68, 68 )' ]
20902090 } ) ;
20912091
20922092 // test arrayOk case
@@ -2113,7 +2113,7 @@ describe('Test hover label custom styling:', function() {
21132113 assertPtLabel ( null ) ;
21142114 assertCommonLabel ( {
21152115 path : [ 'rgb(255, 255, 255)' , 'rgb(68, 68, 68)' ] ,
2116- text : [ 13 , 'Arial' , 'rgb(255, 255, 255 )' ]
2116+ text : [ 13 , 'Arial' , 'rgb(68, 68, 68 )' ]
21172117 } ) ;
21182118
21192119 // test base case
@@ -2203,6 +2203,72 @@ describe('Test hover label custom styling:', function() {
22032203 . then ( done ) ;
22042204 } ) ;
22052205
2206+ it ( 'should work for x/y cartesian traces (multi-trace case)' , function ( done ) {
2207+ var gd = createGraphDiv ( ) ;
2208+
2209+ function assertNameLabel ( expectation ) {
2210+ var g = d3 . selectAll ( 'g.hovertext > text.name' ) ;
2211+
2212+ if ( expectation === null ) {
2213+ expect ( g . size ( ) ) . toBe ( 0 ) ;
2214+ } else {
2215+ g . each ( function ( _ , i ) {
2216+ var textStyle = window . getComputedStyle ( this ) ;
2217+ expect ( textStyle . fill ) . toBe ( expectation . color [ i ] ) ;
2218+ } ) ;
2219+ }
2220+ }
2221+
2222+ Plotly . plot ( gd , [ {
2223+ x : [ 1 , 2 , 3 ] ,
2224+ y : [ 1 , 2 , 1 ] ,
2225+ } , {
2226+ x : [ 1 , 2 , 3 ] ,
2227+ y : [ 4 , 5 , 4 ] ,
2228+ } ] , {
2229+ hovermode : 'x' ,
2230+ } )
2231+ . then ( function ( ) {
2232+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 0 ] } ) ;
2233+ assertNameLabel ( {
2234+ color : [ 'rgb(31, 119, 180)' , 'rgb(255, 127, 14)' ]
2235+ } ) ;
2236+ return Plotly . restyle ( gd , 'marker.color' , [ 'red' , 'blue' ] ) ;
2237+ } )
2238+ . then ( function ( ) {
2239+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 0 ] } ) ;
2240+ assertNameLabel ( {
2241+ color : [ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' ]
2242+ } ) ;
2243+ return Plotly . relayout ( gd , 'hoverlabel.bgcolor' , 'white' ) ;
2244+ } )
2245+ . then ( function ( ) {
2246+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 0 ] } ) ;
2247+ // should not affect the name font color
2248+ assertNameLabel ( {
2249+ color : [ 'rgb(255, 0, 0)' , 'rgb(0, 0, 255)' ]
2250+ } ) ;
2251+ return Plotly . restyle ( gd , 'marker.color' , [ 'rgba(255,0,0,0.1)' , 'rgba(0,0,255,0.1)' ] ) ;
2252+ } )
2253+ . then ( function ( ) {
2254+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 0 ] } ) ;
2255+ // should blend with plot_bgcolor
2256+ assertNameLabel ( {
2257+ color : [ 'rgb(255, 179, 179)' , 'rgb(179, 179, 255)' ]
2258+ } ) ;
2259+ return Plotly . restyle ( gd , 'marker.color' , [ 'rgba(255,0,0,0)' , 'rgba(0,0,255,0)' ] ) ;
2260+ } )
2261+ . then ( function ( ) {
2262+ _hover ( gd , { xval : gd . _fullData [ 0 ] . x [ 0 ] } ) ;
2263+ // uses default line color when opacity=0
2264+ assertNameLabel ( {
2265+ color : [ 'rgb(68, 68, 68)' , 'rgb(68, 68, 68)' ]
2266+ } ) ;
2267+ } )
2268+ . catch ( failTest )
2269+ . then ( done ) ;
2270+ } ) ;
2271+
22062272 it ( 'should work for 2d z cartesian traces' , function ( done ) {
22072273 var gd = createGraphDiv ( ) ;
22082274
0 commit comments