@@ -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' ) ;
@@ -501,8 +502,7 @@ describe('hover info', function() {
501502 nums : 'x: 1\ny: 3\nz: 2' ,
502503 name : 'two'
503504 } ) ;
504- } )
505- . then ( function ( ) {
505+
506506 _hover ( gd , 250 , 300 ) ;
507507 assertHoverLabelContent ( {
508508 nums : 'x: 1\ny: 1\nz: 2' ,
@@ -538,8 +538,7 @@ describe('hover info', function() {
538538 nums : 'x: 1\ny: 3\nz: 2' ,
539539 name : 'two'
540540 } ) ;
541- } )
542- . then ( function ( ) {
541+
543542 _hover ( gd , 250 , 300 ) ;
544543 assertHoverLabelContent ( {
545544 nums : 'x: 1\ny: 1\nz: 5.56' ,
@@ -550,6 +549,45 @@ describe('hover info', function() {
550549 . then ( done ) ;
551550 } ) ;
552551
552+ it ( 'provides exponents correctly for z data' , function ( done ) {
553+ function expFmt ( val , exp ) {
554+ return val + '×10\u200b<tspan style="font-size:70%" dy="-0.6em">' +
555+ ( exp < 0 ? MINUS_SIGN + - exp : exp ) +
556+ '</tspan><tspan dy="0.42em">\u200b</tspan>' ;
557+ }
558+ Plotly . plot ( gd , [ {
559+ type : 'heatmap' ,
560+ y : [ 0 , 1 , 2 , 3 ] ,
561+ z : [
562+ [ - 1.23456789e23 , - 1e10 , - 1e4 ] ,
563+ [ - 1e-2 , - 1e-8 , 0 ] ,
564+ [ 1.23456789e-23 , 1e-8 , 1e-2 ] ,
565+ [ 123.456789 , 1.23456789e10 , 1e23 ]
566+ ] ,
567+ showscale : false
568+ } ] , {
569+ width : 600 ,
570+ height : 400 ,
571+ margin : { l : 0 , t : 0 , r : 0 , b : 0 }
572+ } )
573+ . then ( function ( ) {
574+ [
575+ [ expFmt ( MINUS_SIGN + '1.234568' , 23 ) , MINUS_SIGN + '10B' , MINUS_SIGN + '10k' ] ,
576+ [ MINUS_SIGN + '0.01' , MINUS_SIGN + '10n' , '0' ] ,
577+ [ expFmt ( '1.234568' , - 23 ) , '10n' , '0.01' ] ,
578+ [ '123.4568' , '12.34568B' , expFmt ( '1' , 23 ) ]
579+ ]
580+ . forEach ( function ( row , y ) {
581+ row . forEach ( function ( zVal , x ) {
582+ _hover ( gd , ( x + 0.5 ) * 200 , ( 3.5 - y ) * 100 ) ;
583+ assertHoverLabelContent ( { nums : 'x: ' + x + '\ny: ' + y + '\nz: ' + zVal } , zVal ) ;
584+ } ) ;
585+ } ) ;
586+ } )
587+ . catch ( fail )
588+ . then ( done ) ;
589+ } ) ;
590+
553591 it ( 'should display correct label content with specified format - contour' , function ( done ) {
554592 Plotly . plot ( gd , [ {
555593 type : 'contour' ,
@@ -575,8 +613,7 @@ describe('hover info', function() {
575613 nums : 'x: 1\ny: 3\nz: 2' ,
576614 name : 'two'
577615 } ) ;
578- } )
579- . then ( function ( ) {
616+
580617 _hover ( gd , 250 , 300 ) ;
581618 assertHoverLabelContent ( {
582619 nums : 'x: 1\ny: 1\nz: 5.56' ,
@@ -684,8 +721,7 @@ describe('hover info', function() {
684721 nums : 'x: 1\ny: 3\nz: 2' ,
685722 name : 'two'
686723 } ) ;
687- } )
688- . then ( function ( ) {
724+
689725 _hover ( gd , 250 , 300 ) ;
690726 assertHoverLabelContent ( {
691727 nums : 'x: 1\ny: 1\nz: 5.56' ,
@@ -723,8 +759,7 @@ describe('hover info', function() {
723759 nums : 'x: 1\ny: 3\nz: 2' ,
724760 name : 'two'
725761 } ) ;
726- } )
727- . then ( function ( ) {
762+
728763 _hover ( gd , 250 , 270 ) ;
729764 assertHoverLabelContent ( {
730765 nums : 'x: 1\ny: 1\nz: 5.56' ,
0 commit comments