@@ -187,23 +187,39 @@ describe('pie hovering', function() {
187
187
188
188
function _hover ( ) {
189
189
mouseEvent ( 'mouseover' , 223 , 143 ) ;
190
+ delete gd . _lastHoverTime ;
190
191
}
191
192
192
- function assertLabel ( expected ) {
193
- var labels = d3 . selectAll ( '.hovertext .nums .line' ) ;
193
+ function assertLabel ( content , style ) {
194
+ var g = d3 . selectAll ( '.hovertext' ) ;
195
+ var lines = g . selectAll ( '.nums .line' ) ;
194
196
195
- expect ( labels . size ( ) ) . toBe ( expected . length ) ;
197
+ expect ( lines . size ( ) ) . toBe ( content . length ) ;
196
198
197
- labels . each ( function ( _ , i ) {
198
- expect ( d3 . select ( this ) . text ( ) ) . toBe ( expected [ i ] ) ;
199
+ lines . each ( function ( _ , i ) {
200
+ expect ( d3 . select ( this ) . text ( ) ) . toBe ( content [ i ] ) ;
199
201
} ) ;
202
+
203
+ if ( style ) {
204
+ var path = g . select ( 'path' ) ;
205
+ expect ( path . style ( 'fill' ) ) . toEqual ( style [ 0 ] , 'bgcolor' ) ;
206
+ expect ( path . style ( 'stroke' ) ) . toEqual ( style [ 1 ] , 'bordercolor' ) ;
207
+
208
+ var text = g . select ( 'text' ) ;
209
+ expect ( parseInt ( text . style ( 'font-size' ) ) ) . toEqual ( style [ 2 ] , 'font.size' ) ;
210
+ expect ( text . style ( 'font-family' ) . split ( ',' ) [ 0 ] ) . toEqual ( style [ 3 ] , 'font.family' ) ;
211
+ expect ( text . style ( 'fill' ) ) . toEqual ( style [ 4 ] , 'font.color' ) ;
212
+ }
200
213
}
201
214
202
215
it ( 'should show the default selected values' , function ( done ) {
203
216
Plotly . plot ( gd , mockCopy . data , mockCopy . layout )
204
217
. then ( _hover )
205
218
. then ( function ( ) {
206
- assertLabel ( [ '4' , '5' , '33.3%' ] ) ;
219
+ assertLabel (
220
+ [ '4' , '5' , '33.3%' ] ,
221
+ [ 'rgb(31, 119, 180)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ]
222
+ ) ;
207
223
208
224
return Plotly . restyle ( gd , 'text' , [ [ 'A' , 'B' , 'C' , 'D' , 'E' ] ] ) ;
209
225
} )
@@ -224,7 +240,23 @@ describe('pie hovering', function() {
224
240
. then ( _hover )
225
241
. then ( function ( ) {
226
242
assertLabel ( [ '4' , 'SUP' , '5' , '33.3%' ] ) ;
243
+
244
+ return Plotly . restyle ( gd , {
245
+ 'hoverlabel.bgcolor' : [ [ 'red' , 'green' , 'blue' ] ] ,
246
+ 'hoverlabel.bordercolor' : 'yellow' ,
247
+ 'hoverlabel.font.size' : [ [ 15 , 20 , 30 ] ] ,
248
+ 'hoverlabel.font.family' : 'Roboto' ,
249
+ 'hoverlabel.font.color' : 'blue'
250
+ } ) ;
251
+ } )
252
+ . then ( _hover )
253
+ . then ( function ( ) {
254
+ assertLabel (
255
+ [ '4' , 'SUP' , '5' , '33.3%' ] ,
256
+ [ 'rgb(255, 0, 0)' , 'rgb(255, 255, 0)' , 15 , 'Roboto' , 'rgb(0, 0, 255)' ]
257
+ ) ;
227
258
} )
259
+ . catch ( fail )
228
260
. then ( done ) ;
229
261
} ) ;
230
262
0 commit comments