@@ -35,17 +35,35 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
3535
3636 var posVal , sizeVal , posLetter , sizeLetter , dx , dy , pRangeCalc ;
3737
38+ if ( trace . orientation === 'h' ) {
39+ posVal = yval ;
40+ sizeVal = xval ;
41+ posLetter = 'y' ;
42+ sizeLetter = 'x' ;
43+ dx = sizeFn ;
44+ dy = positionFn ;
45+ } else {
46+ posVal = xval ;
47+ sizeVal = yval ;
48+ posLetter = 'x' ;
49+ sizeLetter = 'y' ;
50+ dy = sizeFn ;
51+ dx = positionFn ;
52+ }
53+
54+ var period = trace [ posLetter + 'period' ] ;
55+
3856 function thisBarMinPos ( di ) { return thisBarExtPos ( di , - 1 ) ; }
3957 function thisBarMaxPos ( di ) { return thisBarExtPos ( di , 1 ) ; }
4058
4159 function thisBarExtPos ( di , sgn ) {
42- if ( di . orig_p !== undefined ) {
60+ if ( period ) {
4361 return di . p + sgn * Math . abs ( di . p - di . orig_p ) ;
4462 }
4563 return di [ posLetter ] + sgn * di . w / 2 ;
4664 }
4765
48- var minPos = isClosest || trace [ posLetter + ' period' ] ?
66+ var minPos = isClosest || period ?
4967 thisBarMinPos :
5068 function ( di ) {
5169 /*
@@ -63,7 +81,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
6381 return Math . min ( thisBarMinPos ( di ) , di . p - t . bardelta / 2 ) ;
6482 } ;
6583
66- var maxPos = isClosest || trace [ posLetter + ' period' ] ?
84+ var maxPos = isClosest || period ?
6785 thisBarMaxPos :
6886 function ( di ) {
6987 return Math . max ( thisBarMaxPos ( di ) , di . p + t . bardelta / 2 ) ;
@@ -121,22 +139,6 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
121139 return Fx . inbox ( b - v , s - v , maxSpikeDistance + ( s - v ) / ( s - b ) - 1 ) ;
122140 }
123141
124- if ( trace . orientation === 'h' ) {
125- posVal = yval ;
126- sizeVal = xval ;
127- posLetter = 'y' ;
128- sizeLetter = 'x' ;
129- dx = sizeFn ;
130- dy = positionFn ;
131- } else {
132- posVal = xval ;
133- sizeVal = yval ;
134- posLetter = 'x' ;
135- sizeLetter = 'y' ;
136- dy = sizeFn ;
137- dx = positionFn ;
138- }
139-
140142 var pa = pointData [ posLetter + 'a' ] ;
141143 var sa = pointData [ sizeLetter + 'a' ] ;
142144
0 commit comments