@@ -4,6 +4,7 @@ var Plotly = require('@lib/index');
4
4
var Fx = require ( '@src/components/fx' ) ;
5
5
var Lib = require ( '@src/lib' ) ;
6
6
var HOVERMINTIME = require ( '@src/components/fx' ) . constants . HOVERMINTIME ;
7
+ var MINUS_SIGN = require ( '@src/constants/numerical' ) . MINUS_SIGN ;
7
8
8
9
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
9
10
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
@@ -501,8 +502,7 @@ describe('hover info', function() {
501
502
nums : 'x: 1\ny: 3\nz: 2' ,
502
503
name : 'two'
503
504
} ) ;
504
- } )
505
- . then ( function ( ) {
505
+
506
506
_hover ( gd , 250 , 300 ) ;
507
507
assertHoverLabelContent ( {
508
508
nums : 'x: 1\ny: 1\nz: 2' ,
@@ -538,8 +538,7 @@ describe('hover info', function() {
538
538
nums : 'x: 1\ny: 3\nz: 2' ,
539
539
name : 'two'
540
540
} ) ;
541
- } )
542
- . then ( function ( ) {
541
+
543
542
_hover ( gd , 250 , 300 ) ;
544
543
assertHoverLabelContent ( {
545
544
nums : 'x: 1\ny: 1\nz: 5.56' ,
@@ -550,6 +549,45 @@ describe('hover info', function() {
550
549
. then ( done ) ;
551
550
} ) ;
552
551
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
+
553
591
it ( 'should display correct label content with specified format - contour' , function ( done ) {
554
592
Plotly . plot ( gd , [ {
555
593
type : 'contour' ,
@@ -575,8 +613,7 @@ describe('hover info', function() {
575
613
nums : 'x: 1\ny: 3\nz: 2' ,
576
614
name : 'two'
577
615
} ) ;
578
- } )
579
- . then ( function ( ) {
616
+
580
617
_hover ( gd , 250 , 300 ) ;
581
618
assertHoverLabelContent ( {
582
619
nums : 'x: 1\ny: 1\nz: 5.56' ,
@@ -684,8 +721,7 @@ describe('hover info', function() {
684
721
nums : 'x: 1\ny: 3\nz: 2' ,
685
722
name : 'two'
686
723
} ) ;
687
- } )
688
- . then ( function ( ) {
724
+
689
725
_hover ( gd , 250 , 300 ) ;
690
726
assertHoverLabelContent ( {
691
727
nums : 'x: 1\ny: 1\nz: 5.56' ,
@@ -723,8 +759,7 @@ describe('hover info', function() {
723
759
nums : 'x: 1\ny: 3\nz: 2' ,
724
760
name : 'two'
725
761
} ) ;
726
- } )
727
- . then ( function ( ) {
762
+
728
763
_hover ( gd , 250 , 270 ) ;
729
764
assertHoverLabelContent ( {
730
765
nums : 'x: 1\ny: 1\nz: 5.56' ,
0 commit comments