@@ -66,7 +66,7 @@ describe('contour defaults', function() {
6666
6767 it ( 'should default connectgaps to false if `z` is not a one dimensional array' , function ( ) {
6868 traceIn = {
69- type : 'heatmap ' ,
69+ type : 'contour ' ,
7070 z : [ [ 0 , null ] , [ 1 , 2 ] ]
7171 } ;
7272
@@ -76,7 +76,7 @@ describe('contour defaults', function() {
7676
7777 it ( 'should default connectgaps to true if `z` is a one dimensional array' , function ( ) {
7878 traceIn = {
79- type : 'heatmap ' ,
79+ type : 'contour ' ,
8080 x : [ 0 , 1 , 0 , 1 ] ,
8181 y : [ 0 , 0 , 1 , 1 ] ,
8282 z : [ 0 , null , 1 , 2 ]
@@ -591,3 +591,61 @@ describe('contour plotting and editing', function() {
591591 . then ( done ) ;
592592 } ) ;
593593} ) ;
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