@@ -528,19 +528,10 @@ describe('heatmap hover', function() {
528
528
529
529
var gd ;
530
530
531
- beforeAll ( function ( done ) {
531
+ beforeAll ( function ( ) {
532
532
jasmine . addMatchers ( customMatchers ) ;
533
-
534
- gd = createGraphDiv ( ) ;
535
-
536
- var mock = require ( '@mocks/heatmap_multi-trace.json' ) ,
537
- mockCopy = Lib . extendDeep ( { } , mock ) ;
538
-
539
- Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
540
533
} ) ;
541
534
542
- afterAll ( destroyGraphDiv ) ;
543
-
544
535
function _hover ( gd , xval , yval ) {
545
536
var fullLayout = gd . _fullLayout ,
546
537
calcData = gd . calcdata ,
@@ -563,24 +554,73 @@ describe('heatmap hover', function() {
563
554
return hoverData ;
564
555
}
565
556
566
- function assertLabels ( hoverPoint , xLabel , yLabel , zLabel ) {
557
+ function assertLabels ( hoverPoint , xLabel , yLabel , zLabel , text ) {
567
558
expect ( hoverPoint . xLabelVal ) . toEqual ( xLabel , 'have correct x label' ) ;
568
559
expect ( hoverPoint . yLabelVal ) . toEqual ( yLabel , 'have correct y label' ) ;
569
560
expect ( hoverPoint . zLabelVal ) . toEqual ( zLabel , 'have correct z label' ) ;
561
+ expect ( hoverPoint . text ) . toEqual ( text , 'have correct text label' ) ;
570
562
}
571
563
572
- it ( 'should find closest point (case 1) and should' , function ( ) {
573
- var pt = _hover ( gd , 0.5 , 0.5 ) [ 0 ] ;
564
+ describe ( 'for `heatmap_multi-trace`' , function ( ) {
574
565
575
- expect ( pt . index ) . toEqual ( [ 1 , 0 ] , 'have correct index' ) ;
576
- assertLabels ( pt , 1 , 1 , 4 ) ;
577
- } ) ;
566
+ beforeAll ( function ( done ) {
567
+ gd = createGraphDiv ( ) ;
568
+
569
+ var mock = require ( '@mocks/heatmap_multi-trace.json' ) ,
570
+ mockCopy = Lib . extendDeep ( { } , mock ) ;
571
+
572
+ Plotly . plot ( gd , mockCopy . data , mockCopy . layout ) . then ( done ) ;
573
+ } ) ;
574
+
575
+ afterAll ( destroyGraphDiv ) ;
576
+
577
+ it ( 'should find closest point (case 1) and should' , function ( ) {
578
+ var pt = _hover ( gd , 0.5 , 0.5 ) [ 0 ] ;
579
+
580
+ expect ( pt . index ) . toEqual ( [ 1 , 0 ] , 'have correct index' ) ;
581
+ assertLabels ( pt , 1 , 1 , 4 ) ;
582
+ } ) ;
578
583
579
- it ( 'should find closest point (case 2) and should' , function ( ) {
580
- var pt = _hover ( gd , 1.5 , 0.5 ) [ 0 ] ;
584
+ it ( 'should find closest point (case 2) and should' , function ( ) {
585
+ var pt = _hover ( gd , 1.5 , 0.5 ) [ 0 ] ;
581
586
582
- expect ( pt . index ) . toEqual ( [ 0 , 0 ] , 'have correct index' ) ;
583
- assertLabels ( pt , 2 , 0.2 , 6 ) ;
587
+ expect ( pt . index ) . toEqual ( [ 0 , 0 ] , 'have correct index' ) ;
588
+ assertLabels ( pt , 2 , 0.2 , 6 ) ;
589
+ } ) ;
584
590
} ) ;
585
591
592
+ describe ( 'for xyz-column traces' , function ( ) {
593
+
594
+ beforeAll ( function ( done ) {
595
+ gd = createGraphDiv ( ) ;
596
+
597
+ Plotly . plot ( gd , [ {
598
+ type : 'heatmap' ,
599
+ x : [ 1 , 2 , 3 ] ,
600
+ y : [ 1 , 1 , 1 ] ,
601
+ z : [ 10 , 4 , 20 ] ,
602
+ text : [ 'a' , 'b' , 'c' ] ,
603
+ hoverinfo : 'text'
604
+ } ] )
605
+ . then ( done ) ;
606
+ } ) ;
607
+
608
+ afterAll ( destroyGraphDiv ) ;
609
+
610
+ it ( 'should find closest point and should' , function ( done ) {
611
+ var pt = _hover ( gd , 0.5 , 0.5 ) [ 0 ] ;
612
+
613
+ expect ( pt . index ) . toEqual ( [ 0 , 0 ] , 'have correct index' ) ;
614
+ assertLabels ( pt , 1 , 1 , 10 , 'a' ) ;
615
+
616
+ Plotly . relayout ( gd , 'xaxis.range' , [ 1 , 2 ] ) . then ( function ( ) {
617
+ var pt2 = _hover ( gd , 1.5 , 0.5 ) [ 0 ] ;
618
+
619
+ expect ( pt2 . index ) . toEqual ( [ 0 , 1 ] , 'have correct index' ) ;
620
+ assertLabels ( pt2 , 2 , 1 , 4 , 'b' ) ;
621
+ } )
622
+ . then ( done ) ;
623
+ } ) ;
624
+
625
+ } ) ;
586
626
} ) ;
0 commit comments