@@ -37,7 +37,10 @@ describe('@gl Test gl3d plots', function() {
3737 var mock3 = require ( '@mocks/gl3d_autocolorscale' ) ;
3838
3939 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 ) ;
4144 if ( textLabel ) content . push ( textLabel ) ;
4245 assertHoverLabelContent ( { nums : content . join ( '\n' ) } ) ;
4346 }
@@ -194,6 +197,16 @@ describe('@gl Test gl3d plots', function() {
194197 . then ( _hover )
195198 . then ( function ( ) {
196199 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' ) ;
197210 } )
198211 . catch ( fail )
199212 . then ( done ) ;
@@ -274,6 +287,23 @@ describe('@gl Test gl3d plots', function() {
274287 'colorbar.tickvals' : undefined ,
275288 'colorbar.ticktext' : undefined
276289 } ) ;
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!' ) ;
277307 } )
278308 . then ( done ) ;
279309 } ) ;
@@ -303,6 +333,60 @@ describe('@gl Test gl3d plots', function() {
303333 . then ( done ) ;
304334 } ) ;
305335
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+
306390 it ( 'should be able to reversibly change trace type' , function ( done ) {
307391 var _mock = Lib . extendDeep ( { } , mock2 ) ;
308392 var sceneLayout = { aspectratio : { x : 1 , y : 1 , z : 1 } } ;
0 commit comments