@@ -4,6 +4,7 @@ var Plotly = require('@lib/index');
44var Fx = require ( '@src/components/fx' ) ;
55var Lib = require ( '@src/lib' ) ;
66var HOVERMINTIME = require ( '@src/components/fx' ) . constants . HOVERMINTIME ;
7+ var MINUS_SIGN = require ( '@src/constants/numerical' ) . MINUS_SIGN ;
78
89var createGraphDiv = require ( '../assets/create_graph_div' ) ;
910var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
@@ -550,6 +551,45 @@ describe('hover info', function() {
550551 . then ( done ) ;
551552 } ) ;
552553
554+ it ( 'provides exponents correctly for z data' , function ( done ) {
555+ function expFmt ( val , exp ) {
556+ return val + '×10\u200b<tspan style="font-size:70%" dy="-0.6em">' +
557+ ( exp < 0 ? MINUS_SIGN + - exp : exp ) +
558+ '</tspan><tspan dy="0.42em">\u200b</tspan>' ;
559+ }
560+ Plotly . plot ( gd , [ {
561+ type : 'heatmap' ,
562+ y : [ 0 , 1 , 2 , 3 ] ,
563+ z : [
564+ [ - 1.23456789e23 , - 1e10 , - 1e4 ] ,
565+ [ - 1e-2 , - 1e-8 , 0 ] ,
566+ [ 1.23456789e-23 , 1e-8 , 1e-2 ] ,
567+ [ 123.456789 , 1.23456789e10 , 1e23 ]
568+ ] ,
569+ showscale : false
570+ } ] , {
571+ width : 600 ,
572+ height : 400 ,
573+ margin : { l : 0 , t : 0 , r : 0 , b : 0 }
574+ } )
575+ . then ( function ( ) {
576+ [
577+ [ expFmt ( MINUS_SIGN + '1.234568' , 23 ) , MINUS_SIGN + '10B' , MINUS_SIGN + '10k' ] ,
578+ [ MINUS_SIGN + '0.01' , MINUS_SIGN + '10n' , '0' ] ,
579+ [ expFmt ( '1.234568' , - 23 ) , '10n' , '0.01' ] ,
580+ [ '123.4568' , '12.34568B' , expFmt ( '1' , 23 ) ]
581+ ]
582+ . forEach ( function ( row , y ) {
583+ row . forEach ( function ( zVal , x ) {
584+ _hover ( gd , ( x + 0.5 ) * 200 , ( 3.5 - y ) * 100 ) ;
585+ assertHoverLabelContent ( { nums : 'x: ' + x + '\ny: ' + y + '\nz: ' + zVal } , zVal ) ;
586+ } ) ;
587+ } ) ;
588+ } )
589+ . catch ( fail )
590+ . then ( done ) ;
591+ } ) ;
592+
553593 it ( 'should display correct label content with specified format - contour' , function ( done ) {
554594 Plotly . plot ( gd , [ {
555595 type : 'contour' ,
0 commit comments