@@ -16,11 +16,8 @@ var fail = require('../assets/fail_test');
16
16
describe ( 'hover info' , function ( ) {
17
17
'use strict' ;
18
18
19
- var mock = require ( '@mocks/14.json' ) ,
20
- evt = {
21
- clientX : mock . layout . width / 2 ,
22
- clientY : mock . layout . height / 2
23
- } ;
19
+ var mock = require ( '@mocks/14.json' ) ;
20
+ var evt = { xpx : 355 , ypx : 150 } ;
24
21
25
22
afterEach ( destroyGraphDiv ) ;
26
23
@@ -447,7 +444,53 @@ describe('hover info', function() {
447
444
448
445
done ( ) ;
449
446
} ) ;
447
+ } ) ;
448
+ } ) ;
449
+
450
+ describe ( '\'hover info for x/y/z traces' , function ( ) {
451
+ function _hover ( gd , xpx , ypx ) {
452
+ Fx . hover ( gd , { xpx : xpx , ypx : ypx } , 'xy' ) ;
453
+ delete gd . _lastHoverTime ;
454
+ }
455
+
456
+ function _assert ( nameLabel , lines ) {
457
+ expect ( d3 . select ( 'g.axistext' ) . size ( ) ) . toEqual ( 0 , 'no common label' ) ;
458
+
459
+ var sel = d3 . select ( 'g.hovertext' ) ;
460
+ expect ( sel . select ( 'text.name' ) . html ( ) ) . toEqual ( nameLabel , 'name label' ) ;
461
+ sel . select ( 'text.nums' ) . selectAll ( 'tspan' ) . each ( function ( _ , i ) {
462
+ expect ( d3 . select ( this ) . html ( ) ) . toEqual ( lines [ i ] , 'lines ' + i ) ;
463
+ } ) ;
464
+ }
450
465
466
+ it ( 'should display correct label content' , function ( done ) {
467
+ var gd = createGraphDiv ( ) ;
468
+
469
+ Plotly . plot ( gd , [ {
470
+ type : 'heatmap' ,
471
+ y : [ 0 , 1 ] ,
472
+ z : [ [ 1 , 2 , 3 ] , [ 2 , 2 , 1 ] ] ,
473
+ name : 'one' ,
474
+ } , {
475
+ type : 'heatmap' ,
476
+ y : [ 2 , 3 ] ,
477
+ z : [ [ 1 , 2 , 3 ] , [ 2 , 2 , 1 ] ] ,
478
+ name : 'two'
479
+ } ] , {
480
+ width : 500 ,
481
+ height : 400 ,
482
+ margin : { l : 0 , t : 0 , r : 0 , b : 0 }
483
+ } )
484
+ . then ( function ( ) {
485
+ _hover ( gd , 250 , 100 ) ;
486
+ _assert ( 'two' , [ 'x: 1' , 'y: 3' , 'z: 2' ] ) ;
487
+ } )
488
+ . then ( function ( ) {
489
+ _hover ( gd , 250 , 300 ) ;
490
+ _assert ( 'one' , [ 'x: 1' , 'y: 1' , 'z: 2' ] ) ;
491
+ } )
492
+ . catch ( fail )
493
+ . then ( done ) ;
451
494
} ) ;
452
495
} ) ;
453
496
0 commit comments