@@ -35,17 +35,35 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
35
35
36
36
var posVal , sizeVal , posLetter , sizeLetter , dx , dy , pRangeCalc ;
37
37
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
+
38
56
function thisBarMinPos ( di ) { return thisBarExtPos ( di , - 1 ) ; }
39
57
function thisBarMaxPos ( di ) { return thisBarExtPos ( di , 1 ) ; }
40
58
41
59
function thisBarExtPos ( di , sgn ) {
42
- if ( di . orig_p !== undefined ) {
60
+ if ( period ) {
43
61
return di . p + sgn * Math . abs ( di . p - di . orig_p ) ;
44
62
}
45
63
return di [ posLetter ] + sgn * di . w / 2 ;
46
64
}
47
65
48
- var minPos = isClosest || trace [ posLetter + ' period' ] ?
66
+ var minPos = isClosest || period ?
49
67
thisBarMinPos :
50
68
function ( di ) {
51
69
/*
@@ -63,7 +81,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
63
81
return Math . min ( thisBarMinPos ( di ) , di . p - t . bardelta / 2 ) ;
64
82
} ;
65
83
66
- var maxPos = isClosest || trace [ posLetter + ' period' ] ?
84
+ var maxPos = isClosest || period ?
67
85
thisBarMaxPos :
68
86
function ( di ) {
69
87
return Math . max ( thisBarMaxPos ( di ) , di . p + t . bardelta / 2 ) ;
@@ -121,22 +139,6 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
121
139
return Fx . inbox ( b - v , s - v , maxSpikeDistance + ( s - v ) / ( s - b ) - 1 ) ;
122
140
}
123
141
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
-
140
142
var pa = pointData [ posLetter + 'a' ] ;
141
143
var sa = pointData [ sizeLetter + 'a' ] ;
142
144
0 commit comments