@@ -37,7 +37,10 @@ describe('@gl Test gl3d plots', function() {
37
37
var mock3 = require ( '@mocks/gl3d_autocolorscale' ) ;
38
38
39
39
function assertHoverText ( xLabel , yLabel , zLabel , textLabel ) {
40
- var content = [ xLabel , yLabel , zLabel ] ;
40
+ var content = [ ] ;
41
+ if ( xLabel ) content . push ( xLabel ) ;
42
+ if ( yLabel ) content . push ( yLabel ) ;
43
+ if ( zLabel ) content . push ( zLabel ) ;
41
44
if ( textLabel ) content . push ( textLabel ) ;
42
45
assertHoverLabelContent ( { nums : content . join ( '\n' ) } ) ;
43
46
}
@@ -194,6 +197,16 @@ describe('@gl Test gl3d plots', function() {
194
197
. then ( _hover )
195
198
. then ( function ( ) {
196
199
assertHoverText ( 'x: 二 6, 2017' , 'y: c' , 'z: 100k' , 'Clementine' ) ;
200
+
201
+ return Plotly . restyle ( gd , 'hoverinfo' , 'text' ) ;
202
+ } )
203
+ . then ( function ( ) {
204
+ assertHoverText ( null , null , null , 'Clementine' ) ;
205
+
206
+ return Plotly . restyle ( gd , 'hoverinfo' , 'z' ) ;
207
+ } )
208
+ . then ( function ( ) {
209
+ assertHoverText ( null , null , '100k' ) ;
197
210
} )
198
211
. catch ( fail )
199
212
. then ( done ) ;
@@ -274,6 +287,23 @@ describe('@gl Test gl3d plots', function() {
274
287
'colorbar.tickvals' : undefined ,
275
288
'colorbar.ticktext' : undefined
276
289
} ) ;
290
+
291
+ return Plotly . restyle ( gd , 'hoverinfo' , 'z' ) ;
292
+ } )
293
+ . then ( _hover )
294
+ . then ( function ( ) {
295
+ assertHoverText ( null , null , '43' ) ;
296
+
297
+ return Plotly . restyle ( gd , 'hoverinfo' , 'text' ) ;
298
+ } )
299
+ . then ( _hover )
300
+ . then ( function ( ) {
301
+ assertHoverText ( null , null , null , 'one two' ) ;
302
+
303
+ return Plotly . restyle ( gd , 'text' , 'yo!' ) ;
304
+ } )
305
+ . then ( function ( ) {
306
+ assertHoverText ( null , null , null , 'yo!' ) ;
277
307
} )
278
308
. then ( done ) ;
279
309
} ) ;
@@ -303,6 +333,60 @@ describe('@gl Test gl3d plots', function() {
303
333
. then ( done ) ;
304
334
} ) ;
305
335
336
+ it ( 'should display correct hover labels (mesh3d case)' , function ( done ) {
337
+ var x = [ 1 , 1 , 2 , 3 , 4 , 2 ] ;
338
+ var y = [ 2 , 1 , 3 , 4 , 5 , 3 ] ;
339
+ var z = [ 3 , 7 , 4 , 5 , 3.5 , 2 ] ;
340
+ var text = x . map ( function ( _ , i ) {
341
+ return [
342
+ 'ts: ' + x [ i ] ,
343
+ 'hz: ' + y [ i ] ,
344
+ 'ftt:' + z [ i ]
345
+ ] . join ( '<br>' ) ;
346
+ } ) ;
347
+
348
+ function _hover ( ) {
349
+ mouseEvent ( 'mouseover' , 250 , 250 ) ;
350
+ return delay ( 20 ) ( ) ;
351
+ }
352
+
353
+ Plotly . newPlot ( gd , [ {
354
+ type : 'mesh3d' ,
355
+ x : x ,
356
+ y : y ,
357
+ z : z ,
358
+ text : text
359
+ } ] , {
360
+ width : 500 ,
361
+ height : 500
362
+ } )
363
+ . then ( delay ( 20 ) )
364
+ . then ( _hover )
365
+ . then ( function ( ) {
366
+ assertHoverText ( 'x: 3' , 'y: 4' , 'z: 5' , 'ts: 3\nhz: 4\nftt:5' ) ;
367
+ } )
368
+ . then ( function ( ) {
369
+ return Plotly . restyle ( gd , 'hoverinfo' , 'x+y' ) ;
370
+ } )
371
+ . then ( function ( ) {
372
+ assertHoverText ( '(3, 4)' ) ;
373
+ } )
374
+ . then ( function ( ) {
375
+ return Plotly . restyle ( gd , 'hoverinfo' , 'text' ) ;
376
+ } )
377
+ . then ( function ( ) {
378
+ assertHoverText ( 'ts: 3\nhz: 4\nftt:5' ) ;
379
+ } )
380
+ . then ( function ( ) {
381
+ return Plotly . restyle ( gd , 'text' , 'yo!' ) ;
382
+ } )
383
+ . then ( function ( ) {
384
+ assertHoverText ( null , null , null , 'yo!' ) ;
385
+ } )
386
+ . catch ( fail )
387
+ . then ( done ) ;
388
+ } ) ;
389
+
306
390
it ( 'should be able to reversibly change trace type' , function ( done ) {
307
391
var _mock = Lib . extendDeep ( { } , mock2 ) ;
308
392
var sceneLayout = { aspectratio : { x : 1 , y : 1 , z : 1 } } ;
0 commit comments