@@ -77,13 +77,16 @@ module.exports = function(gd) {
77
77
// for all present range sliders
78
78
rangeSliders . each ( function ( axisOpts ) {
79
79
var rangeSlider = d3 . select ( this ) ,
80
- opts = axisOpts [ constants . name ] ;
80
+ opts = axisOpts [ constants . name ] ,
81
+ oppAxisOpts = fullLayout [ Axes . id2name ( axisOpts . anchor ) ] ;
81
82
82
83
// update range slider dimensions
83
84
84
85
var margin = fullLayout . margin ,
85
86
graphSize = fullLayout . _size ,
86
- domain = axisOpts . domain ;
87
+ domain = axisOpts . domain ,
88
+ oppDomain = oppAxisOpts . domain ,
89
+ tickHeight = ( axisOpts . _boundingBox || { } ) . height || 0 ;
87
90
88
91
opts . _id = constants . name + axisOpts . _id ;
89
92
opts . _clipId = opts . _id + '-' + fullLayout . _uid ;
@@ -92,8 +95,13 @@ module.exports = function(gd) {
92
95
opts . _height = ( fullLayout . height - margin . b - margin . t ) * opts . thickness ;
93
96
opts . _offsetShift = Math . floor ( opts . borderwidth / 2 ) ;
94
97
95
- var x = margin . l + ( graphSize . w * domain [ 0 ] ) ,
96
- y = fullLayout . height - opts . _height - margin . b ;
98
+ var x = margin . l + ( graphSize . w * domain [ 0 ] ) ;
99
+
100
+ var y = (
101
+ margin . t + graphSize . h * ( 1 - oppDomain [ 0 ] ) +
102
+ tickHeight +
103
+ opts . _offsetShift + constants . extraPad
104
+ ) ;
97
105
98
106
rangeSlider . attr ( 'transform' , 'translate(' + x + ',' + y + ')' ) ;
99
107
@@ -131,23 +139,33 @@ module.exports = function(gd) {
131
139
132
140
// update margins
133
141
134
- var bb = axisOpts . _boundingBox ? axisOpts . _boundingBox . height : 0 ;
135
-
136
142
Plots . autoMargin ( gd , opts . _id , {
137
- x : 0 , y : 0 , l : 0 , r : 0 , t : 0 ,
138
- b : opts . _height + fullLayout . margin . b + bb ,
139
- pad : 15 + opts . _offsetShift * 2
143
+ x : domain [ 0 ] ,
144
+ y : oppDomain [ 0 ] ,
145
+ l : 0 ,
146
+ r : 0 ,
147
+ t : 0 ,
148
+ b : opts . _height + margin . b + tickHeight ,
149
+ pad : constants . extraPad + opts . _offsetShift * 2
140
150
} ) ;
151
+
141
152
} ) ;
142
153
} ;
143
154
144
155
function makeRangeSliderData ( fullLayout ) {
145
- if ( ! fullLayout . xaxis ) return [ ] ;
146
- if ( ! fullLayout . xaxis [ constants . name ] ) return [ ] ;
147
- if ( ! fullLayout . xaxis [ constants . name ] . visible ) return [ ] ;
148
- if ( fullLayout . _has ( 'gl2d' ) ) return [ ] ;
156
+ var axes = Axes . list ( { _fullLayout : fullLayout } , 'x' , true ) ,
157
+ name = constants . name ,
158
+ out = [ ] ;
159
+
160
+ if ( fullLayout . _has ( 'gl2d' ) ) return out ;
149
161
150
- return [ fullLayout . xaxis ] ;
162
+ for ( var i = 0 ; i < axes . length ; i ++ ) {
163
+ var ax = axes [ i ] ;
164
+
165
+ if ( ax [ name ] && ax [ name ] . visible ) out . push ( ax ) ;
166
+ }
167
+
168
+ return out ;
151
169
}
152
170
153
171
function setupDragElement ( rangeSlider , gd , axisOpts , opts ) {
@@ -229,7 +247,7 @@ function setDataRange(rangeSlider, gd, axisOpts, opts) {
229
247
dataMax = clamp ( opts . p2d ( opts . _pixelMax ) ) ;
230
248
231
249
window . requestAnimationFrame ( function ( ) {
232
- Plotly . relayout ( gd , 'xaxis .range', [ dataMin , dataMax ] ) ;
250
+ Plotly . relayout ( gd , axisOpts . _name + ' .range', [ dataMin , dataMax ] ) ;
233
251
} ) ;
234
252
}
235
253
0 commit comments