@@ -4674,7 +4674,7 @@ describe('hovermode: (x|y)unified', function() {
4674
4674
. then ( done , done . fail ) ;
4675
4675
} ) ;
4676
4676
4677
- it ( 'should display hover for scatter and bars at various intervals' , function ( done ) {
4677
+ it ( 'should display hover for scatter and bars at various intervals (default hoverdistance) ' , function ( done ) {
4678
4678
Plotly . newPlot ( gd , {
4679
4679
data : [ {
4680
4680
name : 'bar' ,
@@ -4723,6 +4723,126 @@ describe('hovermode: (x|y)unified', function() {
4723
4723
. then ( done , done . fail ) ;
4724
4724
} ) ;
4725
4725
4726
+ it ( 'should display hover for scatter and bars at various intervals (case of hoverdistance: -1) tests finitRange' , function ( done ) {
4727
+ Plotly . newPlot ( gd , {
4728
+ data : [ {
4729
+ name : 'bar' ,
4730
+ type : 'bar' ,
4731
+ y : [ 10 , 30 ]
4732
+ } , {
4733
+ name : 'scatter' ,
4734
+ type : 'scatter' ,
4735
+ x : [ 0 , 0.2 , 0.4 , 0.6 , 0.8 , 1 ] ,
4736
+ y : [ 21 , 22 , 23 , 24 , 25 , 26 ]
4737
+ } ] ,
4738
+ layout : {
4739
+ hoverdistance : - 1 ,
4740
+ hovermode : 'x unified' ,
4741
+ showlegend : false ,
4742
+ width : 500 ,
4743
+ height : 500 ,
4744
+ margin : {
4745
+ t : 50 ,
4746
+ b : 50 ,
4747
+ l : 50 ,
4748
+ r : 50
4749
+ }
4750
+ }
4751
+ } )
4752
+ . then ( function ( ) {
4753
+ _hover ( gd , { xpx : 100 , ypx : 200 } ) ;
4754
+ assertLabel ( { title : '0' , items : [
4755
+ 'bar : 10' ,
4756
+ 'scatter : 21'
4757
+ ] } ) ;
4758
+ } )
4759
+ . then ( function ( ) {
4760
+ _hover ( gd , { xpx : 200 , ypx : 200 } ) ;
4761
+ assertLabel ( { title : '0.6' , items : [
4762
+ 'bar : (1, 30)' ,
4763
+ 'scatter : 24'
4764
+ ] } ) ;
4765
+ } )
4766
+ . then ( function ( ) {
4767
+ _hover ( gd , { xpx : 300 , ypx : 200 } ) ;
4768
+ assertLabel ( { title : '1' , items : [
4769
+ 'bar : 30' ,
4770
+ 'scatter : 26'
4771
+ ] } ) ;
4772
+ } )
4773
+ . then ( done , done . fail ) ;
4774
+ } ) ;
4775
+
4776
+ it ( 'should display hover for two high-res scatter at different various intervals' , function ( done ) {
4777
+ var x1 = [ ] ;
4778
+ var y1 = [ ] ;
4779
+ var x2 = [ ] ;
4780
+ var y2 = [ ] ;
4781
+ var i , t ;
4782
+
4783
+ function r100 ( v ) {
4784
+ return Math . round ( v * 100 ) ;
4785
+ }
4786
+
4787
+ for ( i = 0 ; i <= 1800 ; i ++ ) {
4788
+ t = i / 180 * Math . PI ;
4789
+ x1 . push ( r100 ( t / 5 ) ) ;
4790
+ y1 . push ( r100 ( Math . sin ( t ) ) ) ;
4791
+ }
4792
+
4793
+ for ( i = 0 ; i <= 360 ; i ++ ) {
4794
+ t = i / 180 * Math . PI ;
4795
+ x2 . push ( r100 ( t ) ) ;
4796
+ y2 . push ( r100 ( Math . sin ( t ) ) ) ;
4797
+ }
4798
+
4799
+ Plotly . newPlot ( gd , {
4800
+ data : [ {
4801
+ name : 'high' ,
4802
+ x : x1 ,
4803
+ y : y1
4804
+ } , {
4805
+ name : 'low' ,
4806
+ x : x2 ,
4807
+ y : y2
4808
+ } ] ,
4809
+ layout : {
4810
+ hovermode : 'x unified' ,
4811
+ showlegend : false ,
4812
+ width : 500 ,
4813
+ height : 500 ,
4814
+ margin : {
4815
+ t : 50 ,
4816
+ b : 50 ,
4817
+ l : 50 ,
4818
+ r : 50
4819
+ }
4820
+ }
4821
+ } )
4822
+ . then ( function ( ) {
4823
+ _hover ( gd , { xpx : 100 , ypx : 200 } ) ;
4824
+ assertLabel ( { title : '157' , items : [
4825
+ 'high : 100' ,
4826
+ 'low : 100'
4827
+ ] } ) ;
4828
+ } )
4829
+ . then ( function ( ) {
4830
+ _hover ( gd , { xpx : 175 , ypx : 200 } ) ;
4831
+ assertLabel ( { title : '275' , items : [
4832
+ 'high : 93' ,
4833
+ 'low : (274, 39)'
4834
+ ] } ) ;
4835
+ } )
4836
+ . then ( function ( ) {
4837
+ _hover ( gd , { xpx : 350 , ypx : 200 } ) ;
4838
+ assertLabel ( { title : '550' , items : [
4839
+ 'high : 68' ,
4840
+ 'low : −71'
4841
+ ] } ) ;
4842
+ } )
4843
+ . then ( done , done . fail ) ;
4844
+ } ) ;
4845
+
4726
4846
it ( 'case of scatter points on period bars' , function ( done ) {
4727
4847
Plotly . newPlot ( gd , {
4728
4848
data : [
0 commit comments