@@ -774,17 +774,30 @@ describe('bar hover', function() {
774774 } ) ;
775775
776776 it ( 'should return the correct hover point data (case y)' , function ( ) {
777- var out = _hover ( gd , 185.645 , 0.15 , 'y' ) ;
777+ var out = _hover ( gd , 0.75 , 0.15 , 'y' ) ,
778+ subplot = gd . _fullLayout . _plots . xy ,
779+ xa = subplot . xaxis ,
780+ ya = subplot . yaxis ,
781+ barDelta = 1 * 0.8 / 2 ;
778782
779- expect ( out . style ) . toEqual ( [ 0 , '#1f77b4' , 75 , 0 ] ) ;
780- assertPos ( out . pos , [ 182.88 , 182.88 , 214.5 , 170.5 ] ) ;
783+ expect ( out . style ) . toEqual ( [ 0 , '#1f77b4' , 0.5 , 0 ] ) ;
784+ assertPos ( out . pos ,
785+ [ xa . c2p ( 0.5 , true ) , xa . c2p ( 0.5 , true ) ,
786+ ya . c2p ( 0 - barDelta , true ) , ya . c2p ( 0 + barDelta , true ) ] ) ;
781787 } ) ;
782788
783789 it ( 'should return the correct hover point data (case closest)' , function ( ) {
784- var out = _hover ( gd , 135.88 , - 0.15 , 'closest' ) ;
785-
786- expect ( out . style ) . toEqual ( [ 0 , '#1f77b4' , 75 , 0 ] ) ;
787- assertPos ( out . pos , [ 182.88 , 182.88 , 214.5 , 192.5 ] ) ;
790+ var out = _hover ( gd , 0.75 , - 0.15 , 'closest' ) ,
791+ subplot = gd . _fullLayout . _plots . xy ,
792+ xa = subplot . xaxis ,
793+ ya = subplot . yaxis ,
794+ barDelta = 1 * 0.8 / 2 / 2 ,
795+ barPos = 0 - 1 * 0.8 / 2 + barDelta ;
796+
797+ expect ( out . style ) . toEqual ( [ 0 , '#1f77b4' , 0.5 , 0 ] ) ;
798+ assertPos ( out . pos ,
799+ [ xa . c2p ( 0.5 , true ) , xa . c2p ( 0.5 , true ) ,
800+ ya . c2p ( barPos - barDelta , true ) , ya . c2p ( barPos + barDelta , true ) ] ) ;
788801 } ) ;
789802 } ) ;
790803
0 commit comments