@@ -24,6 +24,7 @@ mock2.data[0].surfaceaxis = 2;
2424mock2 . layout . showlegend = true ;
2525
2626var mock3 = require ( '@mocks/gl3d_autocolorscale' ) ;
27+ var mock4 = require ( '@mocks/gl3d_transparent_same-depth.json' ) ;
2728
2829describe ( 'Test gl3d trace click/hover:' , function ( ) {
2930 var gd , ptData ;
@@ -39,13 +40,16 @@ describe('Test gl3d trace click/hover:', function() {
3940 destroyGraphDiv ( ) ;
4041 } ) ;
4142
42- function assertHoverText ( xLabel , yLabel , zLabel , textLabel ) {
43+ function assertHoverText ( xLabel , yLabel , zLabel , textLabel , traceName ) {
4344 var content = [ ] ;
4445 if ( xLabel ) content . push ( xLabel ) ;
4546 if ( yLabel ) content . push ( yLabel ) ;
4647 if ( zLabel ) content . push ( zLabel ) ;
4748 if ( textLabel ) content . push ( textLabel ) ;
48- assertHoverLabelContent ( { nums : content . join ( '\n' ) } ) ;
49+ assertHoverLabelContent ( {
50+ name : traceName ,
51+ nums : content . join ( '\n' )
52+ } ) ;
4953 }
5054
5155 function assertEventData ( x , y , z , curveNumber , pointNumber , extra ) {
@@ -539,4 +543,29 @@ describe('Test gl3d trace click/hover:', function() {
539543 . catch ( failTest )
540544 . then ( done ) ;
541545 } ) ;
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+ } ) ;
542571} ) ;
0 commit comments