@@ -66,7 +66,7 @@ describe('contour defaults', function() {
66
66
67
67
it ( 'should default connectgaps to false if `z` is not a one dimensional array' , function ( ) {
68
68
traceIn = {
69
- type : 'heatmap ' ,
69
+ type : 'contour ' ,
70
70
z : [ [ 0 , null ] , [ 1 , 2 ] ]
71
71
} ;
72
72
@@ -76,7 +76,7 @@ describe('contour defaults', function() {
76
76
77
77
it ( 'should default connectgaps to true if `z` is a one dimensional array' , function ( ) {
78
78
traceIn = {
79
- type : 'heatmap ' ,
79
+ type : 'contour ' ,
80
80
x : [ 0 , 1 , 0 , 1 ] ,
81
81
y : [ 0 , 0 , 1 , 1 ] ,
82
82
z : [ 0 , null , 1 , 2 ]
@@ -591,3 +591,61 @@ describe('contour plotting and editing', function() {
591
591
. then ( done ) ;
592
592
} ) ;
593
593
} ) ;
594
+
595
+ describe ( 'contour hover' , function ( ) {
596
+ 'use strict' ;
597
+
598
+ var gd ;
599
+
600
+ function _hover ( gd , xval , yval ) {
601
+ var fullLayout = gd . _fullLayout ;
602
+ var calcData = gd . calcdata ;
603
+ var hoverData = [ ] ;
604
+
605
+ for ( var i = 0 ; i < calcData . length ; i ++ ) {
606
+ var pointData = {
607
+ index : false ,
608
+ distance : 20 ,
609
+ cd : calcData [ i ] ,
610
+ trace : calcData [ i ] [ 0 ] . trace ,
611
+ xa : fullLayout . xaxis ,
612
+ ya : fullLayout . yaxis
613
+ } ;
614
+
615
+ var hoverPoint = Contour . hoverPoints ( pointData , xval , yval ) ;
616
+ if ( hoverPoint ) hoverData . push ( hoverPoint [ 0 ] ) ;
617
+ }
618
+
619
+ return hoverData ;
620
+ }
621
+
622
+ describe ( 'missing data' , function ( ) {
623
+ beforeAll ( function ( done ) {
624
+ gd = createGraphDiv ( ) ;
625
+
626
+ Plotly . plot ( gd , {
627
+ data : [ {
628
+ type : 'contour' ,
629
+ x : [ 10 , 11 , 10 , 11 ] ,
630
+ y : [ 100 , 100 , 101 , 101 ] ,
631
+ z : [ null , 1 , 2 , 3 ] ,
632
+ connectgaps : false ,
633
+ hoverongaps : false
634
+ } ]
635
+ } ) . then ( done ) ;
636
+ } ) ;
637
+ afterAll ( destroyGraphDiv ) ;
638
+
639
+ it ( 'should not display hover on missing data and hoverongaps is disabled' , function ( ) {
640
+ var pt = _hover ( gd , 10 , 100 ) [ 0 ] ;
641
+
642
+ var hoverData ;
643
+ gd . on ( 'plotly_hover' , function ( data ) {
644
+ hoverData = data ;
645
+ } ) ;
646
+
647
+ expect ( hoverData ) . toEqual ( undefined ) ;
648
+ expect ( pt ) . toEqual ( undefined ) ;
649
+ } ) ;
650
+ } ) ;
651
+ } ) ;
0 commit comments