@@ -616,10 +616,11 @@ describe('heatmap hover', function() {
616616 return hoverData ;
617617 }
618618
619- function assertLabels ( hoverPoint , xLabel , yLabel , zLabel , text ) {
620- expect ( hoverPoint . xLabelVal ) . toEqual ( xLabel , 'have correct x label' ) ;
621- expect ( hoverPoint . yLabelVal ) . toEqual ( yLabel , 'have correct y label' ) ;
622- expect ( hoverPoint . zLabelVal ) . toEqual ( zLabel , 'have correct z label' ) ;
619+ function assertLabels ( hoverPoint , xLabelVal , yLabelVal , zLabelVal , zLabel , text ) {
620+ expect ( hoverPoint . xLabelVal ) . toEqual ( xLabelVal , 'have correct x label value' ) ;
621+ expect ( hoverPoint . yLabelVal ) . toEqual ( yLabelVal , 'have correct y label value' ) ;
622+ expect ( hoverPoint . zLabelVal ) . toEqual ( zLabelVal , 'have correct z label value' ) ;
623+ expect ( hoverPoint . zLabel ) . toEqual ( zLabel , 'have correct z label' ) ;
623624 expect ( hoverPoint . text ) . toEqual ( text , 'have correct text label' ) ;
624625 }
625626
@@ -640,14 +641,14 @@ describe('heatmap hover', function() {
640641 var pt = _hover ( gd , 0.5 , 0.5 ) [ 0 ] ;
641642
642643 expect ( pt . index ) . toEqual ( [ 1 , 0 ] , 'have correct index' ) ;
643- assertLabels ( pt , 1 , 1 , 4 ) ;
644+ assertLabels ( pt , 1 , 1 , 4 , '4' ) ;
644645 } ) ;
645646
646647 it ( 'should find closest point (case 2) and should' , function ( ) {
647648 var pt = _hover ( gd , 1.5 , 0.5 ) [ 0 ] ;
648649
649650 expect ( pt . index ) . toEqual ( [ 0 , 0 ] , 'have correct index' ) ;
650- assertLabels ( pt , 2 , 0.2 , 6 ) ;
651+ assertLabels ( pt , 2 , 0.2 , 6 , '6' ) ;
651652 } ) ;
652653 } ) ;
653654
@@ -673,13 +674,47 @@ describe('heatmap hover', function() {
673674 var pt = _hover ( gd , 0.5 , 0.5 ) [ 0 ] ;
674675
675676 expect ( pt . index ) . toEqual ( [ 0 , 0 ] , 'have correct index' ) ;
676- assertLabels ( pt , 1 , 1 , 10 , 'a' ) ;
677+ assertLabels ( pt , 1 , 1 , 10 , '10' , ' a') ;
677678
678679 Plotly . relayout ( gd , 'xaxis.range' , [ 1 , 2 ] ) . then ( function ( ) {
679680 var pt2 = _hover ( gd , 1.5 , 0.5 ) [ 0 ] ;
680681
681682 expect ( pt2 . index ) . toEqual ( [ 0 , 1 ] , 'have correct index' ) ;
682- assertLabels ( pt2 , 2 , 1 , 4 , 'b' ) ;
683+ assertLabels ( pt2 , 2 , 1 , 4 , '4' , 'b' ) ;
684+ } )
685+ . then ( done ) ;
686+ } ) ;
687+
688+ } ) ;
689+
690+ describe ( 'for hovering with specific number format' , function ( ) {
691+
692+ beforeAll ( function ( done ) {
693+ gd = createGraphDiv ( ) ;
694+
695+ Plotly . plot ( gd , [ {
696+ type : 'heatmap' ,
697+ x : [ 1 , 2 , 3 ] ,
698+ y : [ 1 , 1 , 1 ] ,
699+ z : [ 0.123456789 , 2.9999 , 4 ] ,
700+ zhoverformat : '.2f'
701+ } ] )
702+ . then ( done ) ;
703+ } ) ;
704+
705+ afterAll ( destroyGraphDiv ) ;
706+
707+ it ( 'should find closest point and should' , function ( done ) {
708+ var pt = _hover ( gd , 0.5 , 0.5 ) [ 0 ] ;
709+
710+ expect ( pt . index ) . toEqual ( [ 0 , 0 ] , 'have correct index' ) ;
711+ assertLabels ( pt , 1 , 1 , 0.123456789 , '0.12' ) ;
712+
713+ Plotly . relayout ( gd , 'xaxis.range' , [ 1 , 2 ] ) . then ( function ( ) {
714+ var pt2 = _hover ( gd , 1.5 , 0.5 ) [ 0 ] ;
715+
716+ expect ( pt2 . index ) . toEqual ( [ 0 , 1 ] , 'have correct index' ) ;
717+ assertLabels ( pt2 , 2 , 1 , 2.9999 , '3.00' ) ;
683718 } )
684719 . then ( done ) ;
685720 } ) ;
0 commit comments