@@ -2062,7 +2062,7 @@ describe('Test hover label custom styling:', function() {
2062
2062
} ) ;
2063
2063
assertCommonLabel ( {
2064
2064
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 )' ]
2066
2066
} ) ;
2067
2067
} )
2068
2068
. then ( function ( ) {
@@ -2074,7 +2074,7 @@ describe('Test hover label custom styling:', function() {
2074
2074
} ) ;
2075
2075
assertCommonLabel ( {
2076
2076
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 )' ]
2078
2078
} ) ;
2079
2079
} )
2080
2080
. then ( function ( ) {
@@ -2086,7 +2086,7 @@ describe('Test hover label custom styling:', function() {
2086
2086
} ) ;
2087
2087
assertCommonLabel ( {
2088
2088
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 )' ]
2090
2090
} ) ;
2091
2091
2092
2092
// test arrayOk case
@@ -2113,7 +2113,7 @@ describe('Test hover label custom styling:', function() {
2113
2113
assertPtLabel ( null ) ;
2114
2114
assertCommonLabel ( {
2115
2115
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 )' ]
2117
2117
} ) ;
2118
2118
2119
2119
// test base case
@@ -2203,6 +2203,72 @@ describe('Test hover label custom styling:', function() {
2203
2203
. then ( done ) ;
2204
2204
} ) ;
2205
2205
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
+
2206
2272
it ( 'should work for 2d z cartesian traces' , function ( done ) {
2207
2273
var gd = createGraphDiv ( ) ;
2208
2274
0 commit comments