@@ -58,6 +58,19 @@ describe('Test gl3d plots', function() {
5858 }
5959 }
6060
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+
6174 function assertEventData ( x , y , z , curveNumber , pointNumber ) {
6275 expect ( Object . keys ( ptData ) ) . toEqual ( [
6376 'x' , 'y' , 'z' ,
@@ -101,9 +114,10 @@ describe('Test gl3d plots', function() {
101114 . then ( function ( ) {
102115 assertHoverText ( 'x: 140.72' , 'y: −96.97' , 'z: −96.97' ) ;
103116 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)' ) ;
104118
105119 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 ' ] ]
107121 } ) ;
108122 } )
109123 . then ( _hover )
@@ -146,6 +160,25 @@ describe('Test gl3d plots', function() {
146160 . then ( _hover )
147161 . then ( function ( ) {
148162 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)' ) ;
149182 } )
150183 . then ( done ) ;
151184 } ) ;
@@ -170,6 +203,21 @@ describe('Test gl3d plots', function() {
170203 . then ( function ( ) {
171204 assertHoverText ( 'x: 1' , 'y: 2' , 'z: 43' , 'one two' ) ;
172205 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)' ) ;
173221 } )
174222 . then ( done ) ;
175223 } ) ;
0 commit comments