@@ -463,6 +463,16 @@ describe('hover info', function() {
463
463
Lib . clearThrottle ( ) ;
464
464
}
465
465
466
+ function _hoverNatural ( gd , xpx , ypx ) {
467
+ var gdBB = gd . getBoundingClientRect ( ) ;
468
+ var dragger = gd . querySelector ( '.nsewdrag' ) ;
469
+ var clientX = xpx + gdBB . left + gd . _fullLayout . _size . l ;
470
+ var clientY = ypx + gdBB . top + gd . _fullLayout . _size . t ;
471
+
472
+ Fx . hover ( gd , { clientX : clientX , clientY : clientY , target : dragger } , 'xy' ) ;
473
+ Lib . clearThrottle ( ) ;
474
+ }
475
+
466
476
describe ( '\'hover info for x/y/z traces' , function ( ) {
467
477
it ( 'should display correct label content' , function ( done ) {
468
478
var gd = createGraphDiv ( ) ;
@@ -526,6 +536,7 @@ describe('hover info', function() {
526
536
describe ( 'histogram hover info' , function ( ) {
527
537
it ( 'shows the data range when bins have multiple values' , function ( done ) {
528
538
var gd = createGraphDiv ( ) ;
539
+ var pts ;
529
540
530
541
Plotly . plot ( gd , [ {
531
542
x : [ 0 , 2 , 3 , 4 , 5 , 6 , 7 ] ,
@@ -537,12 +548,28 @@ describe('hover info', function() {
537
548
margin : { l : 0 , t : 0 , r : 0 , b : 0 }
538
549
} )
539
550
. then ( function ( ) {
540
- _hover ( gd , 250 , 200 ) ;
551
+ gd . on ( 'plotly_hover' , function ( e ) { pts = e . points ; } ) ;
552
+
553
+ _hoverNatural ( gd , 250 , 200 ) ;
541
554
assertHoverLabelContent ( {
542
555
nums : '3' ,
543
556
axis : '3 - 5'
544
557
} ) ;
545
558
} )
559
+ . then ( function ( ) {
560
+ expect ( pts . length ) . toBe ( 1 ) ;
561
+ var pt = pts [ 0 ] ;
562
+
563
+ expect ( pt . curveNumber ) . toBe ( 0 ) ;
564
+ expect ( pt . binNumber ) . toBe ( 1 ) ;
565
+ expect ( pt . pointNumbers ) . toEqual ( [ 2 , 3 , 4 ] ) ;
566
+ expect ( pt . x ) . toBe ( 4 ) ;
567
+ expect ( pt . y ) . toBe ( 3 ) ;
568
+ expect ( pt . data ) . toBe ( gd . data [ 0 ] ) ;
569
+ expect ( pt . fullData ) . toBe ( gd . _fullData [ 0 ] ) ;
570
+ expect ( pt . xaxis ) . toBe ( gd . _fullLayout . xaxis ) ;
571
+ expect ( pt . yaxis ) . toBe ( gd . _fullLayout . yaxis ) ;
572
+ } )
546
573
. catch ( fail )
547
574
. then ( done ) ;
548
575
} ) ;
0 commit comments