@@ -474,9 +474,12 @@ describe('hover info', function() {
474
474
}
475
475
476
476
describe ( '\'hover info for x/y/z traces' , function ( ) {
477
- it ( 'should display correct label content' , function ( done ) {
478
- var gd = createGraphDiv ( ) ;
477
+ var gd ;
478
+ beforeEach ( function ( ) {
479
+ gd = createGraphDiv ( ) ;
480
+ } ) ;
479
481
482
+ it ( 'should display correct label content' , function ( done ) {
480
483
Plotly . plot ( gd , [ {
481
484
type : 'heatmap' ,
482
485
y : [ 0 , 1 ] ,
@@ -510,20 +513,20 @@ describe('hover info', function() {
510
513
. then ( done ) ;
511
514
} ) ;
512
515
513
- it ( 'should display correct label content with specified format' , function ( done ) {
514
- var gd = createGraphDiv ( ) ;
515
-
516
+ it ( 'should display correct label content with specified format - heatmap' , function ( done ) {
516
517
Plotly . plot ( gd , [ {
517
518
type : 'heatmap' ,
518
519
y : [ 0 , 1 ] ,
519
520
z : [ [ 1.11111 , 2.2222 , 3.33333 ] , [ 4.44444 , 5.55555 , 6.66666 ] ] ,
520
521
name : 'one' ,
521
- zhoverformat : '.2f'
522
+ zhoverformat : '.2f' ,
523
+ showscale : false
522
524
} , {
523
525
type : 'heatmap' ,
524
526
y : [ 2 , 3 ] ,
525
527
z : [ [ 1 , 2 , 3 ] , [ 2 , 2 , 1 ] ] ,
526
- name : 'two'
528
+ name : 'two' ,
529
+ showscale : false
527
530
} ] , {
528
531
width : 500 ,
529
532
height : 400 ,
@@ -546,6 +549,121 @@ describe('hover info', function() {
546
549
. catch ( fail )
547
550
. then ( done ) ;
548
551
} ) ;
552
+
553
+ it ( 'should display correct label content with specified format - contour' , function ( done ) {
554
+ Plotly . plot ( gd , [ {
555
+ type : 'contour' ,
556
+ y : [ 0 , 1 ] ,
557
+ z : [ [ 1.11111 , 2.2222 , 3.33333 ] , [ 4.44444 , 5.55555 , 6.66666 ] ] ,
558
+ name : 'one' ,
559
+ zhoverformat : '.2f' ,
560
+ showscale : false
561
+ } , {
562
+ type : 'contour' ,
563
+ y : [ 2 , 3 ] ,
564
+ z : [ [ 1 , 2 , 3 ] , [ 2 , 2 , 1 ] ] ,
565
+ name : 'two' ,
566
+ showscale : false
567
+ } ] , {
568
+ width : 500 ,
569
+ height : 400 ,
570
+ margin : { l : 0 , t : 0 , r : 0 , b : 0 }
571
+ } )
572
+ . then ( function ( ) {
573
+ _hover ( gd , 250 , 50 ) ;
574
+ assertHoverLabelContent ( {
575
+ nums : 'x: 1\ny: 3\nz: 2' ,
576
+ name : 'two'
577
+ } ) ;
578
+ } )
579
+ . then ( function ( ) {
580
+ _hover ( gd , 250 , 300 ) ;
581
+ assertHoverLabelContent ( {
582
+ nums : 'x: 1\ny: 1\nz: 5.56' ,
583
+ name : 'one'
584
+ } ) ;
585
+ } )
586
+ . catch ( fail )
587
+ . then ( done ) ;
588
+ } ) ;
589
+
590
+ it ( 'should display correct label content with specified format - histogram2d' , function ( done ) {
591
+ Plotly . plot ( gd , [ {
592
+ type : 'histogram2d' ,
593
+ x : [ 0 , 1 , 2 , 0 , 1 , 2 , 1 ] ,
594
+ y : [ 0 , 0 , 0 , 1 , 1 , 1 , 1 ] ,
595
+ z : [ 1.11111 , 2.2222 , 3.3333 , 4.4444 , 4.4444 , 6.6666 , 1.1111 ] ,
596
+ histfunc : 'sum' ,
597
+ name : 'one' ,
598
+ zhoverformat : '.2f' ,
599
+ showscale : false
600
+ } , {
601
+ type : 'histogram2d' ,
602
+ x : [ 0 , 1 , 2 , 0 , 1 , 2 , 1 , 2 , 0 , 1 , 2 ] ,
603
+ y : [ 2 , 2 , 2 , 3 , 3 , 3 , 2 , 2 , 3 , 3 , 2 ] ,
604
+ name : 'two' ,
605
+ showscale : false
606
+ } ] , {
607
+ width : 500 ,
608
+ height : 400 ,
609
+ margin : { l : 0 , t : 0 , r : 0 , b : 0 }
610
+ } )
611
+ . then ( function ( ) {
612
+ _hover ( gd , 250 , 100 ) ;
613
+ assertHoverLabelContent ( {
614
+ nums : 'x: 1\ny: 3\nz: 2' ,
615
+ name : 'two'
616
+ } ) ;
617
+ } )
618
+ . then ( function ( ) {
619
+ _hover ( gd , 250 , 300 ) ;
620
+ assertHoverLabelContent ( {
621
+ nums : 'x: 1\ny: 1\nz: 5.56' ,
622
+ name : 'one'
623
+ } ) ;
624
+ } )
625
+ . catch ( fail )
626
+ . then ( done ) ;
627
+ } ) ;
628
+
629
+ it ( 'should display correct label content with specified format - histogram2dcontour' , function ( done ) {
630
+ Plotly . plot ( gd , [ {
631
+ type : 'histogram2dcontour' ,
632
+ x : [ 0 , 1 , 2 , 0 , 1 , 2 , 1 ] ,
633
+ y : [ 0 , 0 , 0 , 1 , 1 , 1 , 1 ] ,
634
+ z : [ 1.11111 , 2.2222 , 3.3333 , 4.4444 , 4.4444 , 6.6666 , 1.1111 ] ,
635
+ histfunc : 'sum' ,
636
+ name : 'one' ,
637
+ zhoverformat : '.2f' ,
638
+ showscale : false
639
+ } , {
640
+ type : 'histogram2dcontour' ,
641
+ x : [ 0 , 1 , 2 , 0 , 1 , 2 , 1 , 2 , 0 , 1 , 2 ] ,
642
+ y : [ 2 , 2 , 2 , 3 , 3 , 3 , 2 , 2 , 3 , 3 , 2 ] ,
643
+ name : 'two' ,
644
+ showscale : false
645
+ } ] , {
646
+ width : 500 ,
647
+ height : 400 ,
648
+ margin : { l : 0 , t : 0 , r : 0 , b : 0 }
649
+ } )
650
+ . then ( function ( ) {
651
+ _hover ( gd , 250 , 50 ) ;
652
+ assertHoverLabelContent ( {
653
+ nums : 'x: 1\ny: 3\nz: 2' ,
654
+ name : 'two'
655
+ } ) ;
656
+ } )
657
+ . then ( function ( ) {
658
+ _hover ( gd , 250 , 270 ) ;
659
+ assertHoverLabelContent ( {
660
+ nums : 'x: 1\ny: 1\nz: 5.56' ,
661
+ name : 'one'
662
+ } ) ;
663
+ } )
664
+ . catch ( fail )
665
+ . then ( done ) ;
666
+ } ) ;
549
667
} ) ;
550
668
551
669
describe ( 'hover info for negative data on a log axis' , function ( ) {
0 commit comments