@@ -88,7 +88,7 @@ describe('Test gl plot interactions', function() {
88
88
89
89
describe ( 'scatter3d hover' , function ( ) {
90
90
91
- var node , ptData ;
91
+ var ptData ;
92
92
93
93
beforeEach ( function ( done ) {
94
94
gd . on ( 'plotly_hover' , function ( eventData ) {
@@ -100,14 +100,18 @@ describe('Test gl plot interactions', function() {
100
100
delay ( done ) ;
101
101
} ) ;
102
102
103
- it ( 'should have' , function ( ) {
104
- node = d3 . selectAll ( 'g.hovertext' ) ;
103
+ function assertHoverText ( xLabel , yLabel , zLabel ) {
104
+ var node = d3 . selectAll ( 'g.hovertext' ) ;
105
105
expect ( node . size ( ) ) . toEqual ( 1 , 'one hover text group' ) ;
106
106
107
- node = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] ;
108
- expect ( node [ 0 ] . innerHTML ) . toEqual ( 'x: 140.72' , 'x val on hover' ) ;
109
- expect ( node [ 1 ] . innerHTML ) . toEqual ( 'y: −96.97' , 'y val on hover' ) ;
110
- expect ( node [ 2 ] . innerHTML ) . toEqual ( 'z: −96.97' , 'z val on hover' ) ;
107
+ var tspan = d3 . selectAll ( 'g.hovertext' ) . selectAll ( 'tspan' ) [ 0 ] ;
108
+ expect ( tspan [ 0 ] . innerHTML ) . toEqual ( xLabel , 'x val on hover' ) ;
109
+ expect ( tspan [ 1 ] . innerHTML ) . toEqual ( yLabel , 'y val on hover' ) ;
110
+ expect ( tspan [ 2 ] . innerHTML ) . toEqual ( zLabel , 'z val on hover' ) ;
111
+ }
112
+
113
+ it ( 'should have' , function ( done ) {
114
+ assertHoverText ( 'x: 140.72' , 'y: −96.97' , 'z: −96.97' ) ;
111
115
112
116
expect ( Object . keys ( ptData ) ) . toEqual ( [
113
117
'x' , 'y' , 'z' ,
@@ -119,8 +123,44 @@ describe('Test gl plot interactions', function() {
119
123
expect ( ptData . z ) . toEqual ( '−96.97' , 'z val hover data' ) ;
120
124
expect ( ptData . curveNumber ) . toEqual ( 0 , 'curveNumber hover data' ) ;
121
125
expect ( ptData . pointNumber ) . toEqual ( 2 , 'pointNumber hover data' ) ;
122
- } ) ;
123
126
127
+ Plotly . restyle ( gd , {
128
+ x : [ [ '2016-01-11' , '2016-01-12' , '2017-01-01' , '2017-02' ] ]
129
+ } )
130
+ . then ( function ( ) {
131
+ mouseEventScatter3d ( 'mouseover' ) ;
132
+ return delay ;
133
+ } )
134
+ . then ( function ( ) {
135
+ assertHoverText ( 'x: Jan 1, 2017' , 'y: −96.97' , 'z: −96.97' ) ;
136
+
137
+ return Plotly . restyle ( gd , {
138
+ x : [ [ new Date ( 2017 , 2 , 1 ) , new Date ( 2017 , 2 , 2 ) , new Date ( 2017 , 2 , 3 ) , new Date ( 2017 , 2 , 4 ) ] ]
139
+ } ) ;
140
+ } )
141
+ . then ( function ( ) {
142
+ mouseEventScatter3d ( 'mouseover' ) ;
143
+ return delay ;
144
+ } )
145
+ . then ( function ( ) {
146
+ assertHoverText ( 'x: Mar 3, 2017' , 'y: −96.97' , 'z: −96.97' ) ;
147
+
148
+ return Plotly . update ( gd , {
149
+ y : [ [ 'a' , 'b' , 'c' , 'd' ] ] ,
150
+ z : [ [ 10 , 1e3 , 1e5 , 1e10 ] ]
151
+ } , {
152
+ 'scene.zaxis.type' : 'log'
153
+ } ) ;
154
+ } )
155
+ . then ( function ( ) {
156
+ mouseEventScatter3d ( 'mouseover' ) ;
157
+ return delay ;
158
+ } )
159
+ . then ( function ( ) {
160
+ assertHoverText ( 'x: Mar 3, 2017' , 'y: c' , 'z: 100k' ) ;
161
+ } )
162
+ . then ( done ) ;
163
+ } ) ;
124
164
} ) ;
125
165
126
166
describe ( 'scatter3d click events' , function ( ) {
0 commit comments