@@ -58,6 +58,19 @@ describe('Test gl3d plots', function() {
58
58
}
59
59
}
60
60
61
+ function assertHoverLabelStyle ( bgColor , borderColor , fontSize , fontFamily , fontColor ) {
62
+ var node = d3 . selectAll ( 'g.hovertext' ) ;
63
+
64
+ var path = node . select ( 'path' ) ;
65
+ expect ( path . style ( 'fill' ) ) . toEqual ( bgColor , 'bgcolor' ) ;
66
+ expect ( path . style ( 'stroke' ) ) . toEqual ( borderColor , 'bordercolor' ) ;
67
+
68
+ var text = node . select ( 'text' ) ;
69
+ expect ( parseInt ( text . style ( 'font-size' ) ) ) . toEqual ( fontSize , 'font.size' ) ;
70
+ expect ( text . style ( 'font-family' ) . split ( ',' ) [ 0 ] ) . toEqual ( fontFamily , 'font.family' ) ;
71
+ expect ( text . style ( 'fill' ) ) . toEqual ( fontColor , 'font.color' ) ;
72
+ }
73
+
61
74
function assertEventData ( x , y , z , curveNumber , pointNumber ) {
62
75
expect ( Object . keys ( ptData ) ) . toEqual ( [
63
76
'x' , 'y' , 'z' ,
@@ -101,9 +114,10 @@ describe('Test gl3d plots', function() {
101
114
. then ( function ( ) {
102
115
assertHoverText ( 'x: 140.72' , 'y: −96.97' , 'z: −96.97' ) ;
103
116
assertEventData ( 140.72 , - 96.97 , - 96.97 , 0 , 2 ) ;
117
+ assertHoverLabelStyle ( 'rgb(0, 0, 255)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ) ;
104
118
105
119
return Plotly . restyle ( gd , {
106
- x : [ [ '2016-01-11' , '2016-01-12' , '2017-01-01' , '2017-02' ] ]
120
+ x : [ [ '2016-01-11' , '2016-01-12' , '2017-01-01' , '2017-02-01 ' ] ]
107
121
} ) ;
108
122
} )
109
123
. then ( _hover )
@@ -146,6 +160,25 @@ describe('Test gl3d plots', function() {
146
160
. then ( _hover )
147
161
. then ( function ( ) {
148
162
assertHoverText ( 'x: 二 6, 2017' , 'y: c' , 'z: 100k' , 'Clementine' ) ;
163
+
164
+ return Plotly . restyle ( gd , {
165
+ 'hoverlabel.bgcolor' : [ [ 'red' , 'blue' , 'green' , 'yellow' ] ] ,
166
+ 'hoverlabel.font.size' : 20
167
+ } ) ;
168
+ } )
169
+ . then ( _hover )
170
+ . then ( function ( ) {
171
+ assertHoverLabelStyle ( 'rgb(0, 128, 0)' , 'rgb(255, 255, 255)' , 20 , 'Arial' , 'rgb(255, 255, 255)' ) ;
172
+
173
+ return Plotly . relayout ( gd , {
174
+ 'hoverlabel.bordercolor' : 'yellow' ,
175
+ 'hoverlabel.font.color' : 'cyan' ,
176
+ 'hoverlabel.font.family' : 'Roboto'
177
+ } ) ;
178
+ } )
179
+ . then ( _hover )
180
+ . then ( function ( ) {
181
+ assertHoverLabelStyle ( 'rgb(0, 128, 0)' , 'rgb(255, 255, 0)' , 20 , 'Roboto' , 'rgb(0, 255, 255)' ) ;
149
182
} )
150
183
. then ( done ) ;
151
184
} ) ;
@@ -170,6 +203,21 @@ describe('Test gl3d plots', function() {
170
203
. then ( function ( ) {
171
204
assertHoverText ( 'x: 1' , 'y: 2' , 'z: 43' , 'one two' ) ;
172
205
assertEventData ( 1 , 2 , 43 , 0 , [ 1 , 2 ] ) ;
206
+ assertHoverLabelStyle ( 'rgb(68, 68, 68)' , 'rgb(255, 255, 255)' , 13 , 'Arial' , 'rgb(255, 255, 255)' ) ;
207
+
208
+ Plotly . restyle ( gd , {
209
+ 'hoverlabel.bgcolor' : 'white' ,
210
+ 'hoverlabel.font.size' : 9 ,
211
+ 'hoverlabel.font.color' : [ [
212
+ [ 'red' , 'blue' , 'green' ] ,
213
+ [ 'pink' , 'purple' , 'cyan' ] ,
214
+ [ 'black' , 'orange' , 'yellow' ]
215
+ ] ]
216
+ } ) ;
217
+ } )
218
+ . then ( _hover )
219
+ . then ( function ( ) {
220
+ assertHoverLabelStyle ( 'rgb(255, 255, 255)' , 'rgb(68, 68, 68)' , 9 , 'Arial' , 'rgb(0, 255, 255)' ) ;
173
221
} )
174
222
. then ( done ) ;
175
223
} ) ;
0 commit comments