@@ -4773,6 +4773,78 @@ describe('hovermode: (x|y)unified', function() {
4773
4773
. then ( done , done . fail ) ;
4774
4774
} ) ;
4775
4775
4776
+ it ( 'should pick the bar which is closest to the winning point no the bar that close to the cursor' , function ( done ) {
4777
+ Plotly . newPlot ( gd , {
4778
+ data : [ {
4779
+ name : 'bar' ,
4780
+ type : 'bar' ,
4781
+ y : [ 10 , 20 , 30 ]
4782
+ } , {
4783
+ name : 'scatter' ,
4784
+ type : 'scatter' ,
4785
+ x : [ 0 , 0.49 , 1 , 1.51 , 2 ] ,
4786
+ y : [ 21 , 22 , 23 , 24 , 25 ]
4787
+ } ] ,
4788
+ layout : {
4789
+ hoverdistance : - 1 ,
4790
+ hovermode : 'x unified' ,
4791
+ showlegend : false ,
4792
+ width : 500 ,
4793
+ height : 500 ,
4794
+ margin : {
4795
+ t : 50 ,
4796
+ b : 50 ,
4797
+ l : 50 ,
4798
+ r : 50
4799
+ }
4800
+ }
4801
+ } )
4802
+ . then ( function ( ) {
4803
+ _hover ( gd , { xpx : 0 , ypx : 200 } ) ;
4804
+ assertLabel ( { title : '0' , items : [
4805
+ 'bar : 10' ,
4806
+ 'scatter : 21'
4807
+ ] } ) ;
4808
+
4809
+ _hover ( gd , { xpx : 100 , ypx : 200 } ) ;
4810
+ assertLabel ( { title : '0.49' , items : [
4811
+ 'bar : (0, 10)' ,
4812
+ 'scatter : 22'
4813
+ ] } ) ;
4814
+
4815
+ _hover ( gd , { xpx : 150 , ypx : 200 } ) ;
4816
+ assertLabel ( { title : '0.49' , items : [
4817
+ 'bar : (0, 10)' ,
4818
+ 'scatter : 22'
4819
+ ] } ) ;
4820
+
4821
+ _hover ( gd , { xpx : 200 , ypx : 200 } ) ;
4822
+ assertLabel ( { title : '1' , items : [
4823
+ 'bar : 20' ,
4824
+ 'scatter : 23'
4825
+ ] } ) ;
4826
+
4827
+ _hover ( gd , { xpx : 250 , ypx : 200 } ) ;
4828
+ assertLabel ( { title : '1.51' , items : [
4829
+ 'bar : (2, 30)' ,
4830
+ 'scatter : 24'
4831
+ ] } ) ;
4832
+
4833
+ _hover ( gd , { xpx : 300 , ypx : 200 } ) ;
4834
+ assertLabel ( { title : '1.51' , items : [
4835
+ 'bar : (2, 30)' ,
4836
+ 'scatter : 24'
4837
+ ] } ) ;
4838
+
4839
+ _hover ( gd , { xpx : 400 , ypx : 200 } ) ;
4840
+ assertLabel ( { title : '2' , items : [
4841
+ 'bar : 30' ,
4842
+ 'scatter : 25'
4843
+ ] } ) ;
4844
+ } )
4845
+ . then ( done , done . fail ) ;
4846
+ } ) ;
4847
+
4776
4848
it ( 'should display hover for two high-res scatter at different various intervals' , function ( done ) {
4777
4849
var x1 = [ ] ;
4778
4850
var y1 = [ ] ;
0 commit comments