@@ -24,6 +24,7 @@ mock2.data[0].surfaceaxis = 2;
24
24
mock2 . layout . showlegend = true ;
25
25
26
26
var mock3 = require ( '@mocks/gl3d_autocolorscale' ) ;
27
+ var mock4 = require ( '@mocks/gl3d_transparent_same-depth.json' ) ;
27
28
28
29
describe ( 'Test gl3d trace click/hover:' , function ( ) {
29
30
var gd , ptData ;
@@ -39,13 +40,16 @@ describe('Test gl3d trace click/hover:', function() {
39
40
destroyGraphDiv ( ) ;
40
41
} ) ;
41
42
42
- function assertHoverText ( xLabel , yLabel , zLabel , textLabel ) {
43
+ function assertHoverText ( xLabel , yLabel , zLabel , textLabel , traceName ) {
43
44
var content = [ ] ;
44
45
if ( xLabel ) content . push ( xLabel ) ;
45
46
if ( yLabel ) content . push ( yLabel ) ;
46
47
if ( zLabel ) content . push ( zLabel ) ;
47
48
if ( textLabel ) content . push ( textLabel ) ;
48
- assertHoverLabelContent ( { nums : content . join ( '\n' ) } ) ;
49
+ assertHoverLabelContent ( {
50
+ name : traceName ,
51
+ nums : content . join ( '\n' )
52
+ } ) ;
49
53
}
50
54
51
55
function assertEventData ( x , y , z , curveNumber , pointNumber , extra ) {
@@ -539,4 +543,29 @@ describe('Test gl3d trace click/hover:', function() {
539
543
. catch ( failTest )
540
544
. then ( done ) ;
541
545
} ) ;
546
+
547
+ it ( '@gl should pick latest & closest points on hover if two points overlap' , function ( done ) {
548
+ var _mock = Lib . extendDeep ( { } , mock4 ) ;
549
+
550
+ function _hover ( ) {
551
+ mouseEvent ( 'mouseover' , 0 , 0 ) ;
552
+ mouseEvent ( 'mouseover' , 200 , 200 ) ;
553
+ }
554
+
555
+ Plotly . plot ( gd , _mock )
556
+ . then ( delay ( 20 ) )
557
+ . then ( function ( ) {
558
+ gd . on ( 'plotly_hover' , function ( eventData ) {
559
+ ptData = eventData . points [ 0 ] ;
560
+ } ) ;
561
+ } )
562
+ . then ( delay ( 20 ) )
563
+ . then ( _hover )
564
+ . then ( delay ( 20 ) )
565
+ . then ( function ( ) {
566
+ assertHoverText ( 'x: 1' , 'y: 1' , 'z: 1' , 'third above' , 'trace 1' ) ;
567
+ } )
568
+ . catch ( failTest )
569
+ . then ( done ) ;
570
+ } ) ;
542
571
} ) ;
0 commit comments