Skip to content

Commit ccb6091

Browse files
committed
fix rangeslider.y.rangemode=auto and add a test image
1 parent 73560f6 commit ccb6091

File tree

7 files changed

+821
-691
lines changed

7 files changed

+821
-691
lines changed

src/components/rangeslider/defaults.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
4141
coerce('borderwidth');
4242
coerce('thickness');
4343

44-
coerce('autorange', !axOut.isValidRange(containerIn.range));
44+
axOut._rangesliderAutorange = coerce('autorange', !axOut.isValidRange(containerIn.range));
4545
coerce('range');
4646

4747
var subplots = layoutOut._subplots;
@@ -60,15 +60,18 @@ module.exports = function handleDefaults(layoutIn, layoutOut, axName) {
6060
var rangeContainerIn = containerIn[yName] || {};
6161
var rangeContainerOut = containerOut[yName] = {};
6262

63+
var yAxOut = layoutOut[yName];
64+
6365
var rangemodeDflt;
64-
if(rangeContainerIn.range && layoutOut[yName].isValidRange(rangeContainerIn.range)) {
66+
if(rangeContainerIn.range && yAxOut.isValidRange(rangeContainerIn.range)) {
6567
rangemodeDflt = 'fixed';
6668
}
6769

6870
var rangeMode = coerceRange(rangeContainerIn, rangeContainerOut, 'rangemode', rangemodeDflt);
6971
if(rangeMode !== 'match') {
70-
coerceRange(rangeContainerIn, rangeContainerOut, 'range', layoutOut[yName].range.slice());
72+
coerceRange(rangeContainerIn, rangeContainerOut, 'range', yAxOut.range.slice());
7173
}
74+
yAxOut._rangesliderAutorange = (rangeMode === 'auto');
7275
}
7376
}
7477

src/plots/cartesian/autorange.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ function doAutoRange(ax) {
211211
}
212212

213213
function needsAutorange(ax) {
214-
return ax.autorange || !!(ax.rangeslider || {}).autorange;
214+
return ax.autorange || ax._rangesliderAutorange;
215215
}
216216

217217
/*

src/plots/cartesian/axis_defaults.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,12 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
4949

5050
var autoRange = coerce('autorange', !containerOut.isValidRange(containerIn.range));
5151

52+
// both x and y axes may need autorange done just for the range slider's purposes
53+
// the logic is complicated to figure this out later, particularly for y axes since
54+
// the settings can be spread out in the x axes... so instead we'll collect them
55+
// during supplyDefaults
56+
containerOut._rangesliderAutorange = false;
57+
5258
if(autoRange) coerce('rangemode');
5359

5460
coerce('range');
33.8 KB
Loading
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"data": [
3+
{"y": [4, 7e7, 5e5, 6e8, 3e2], "type": "bar"},
4+
{"y": [1, 4, 2, 6, 3], "xaxis": "x2", "yaxis": "y2"}
5+
],
6+
"layout": {
7+
"xaxis": {
8+
"domain": [0, 0.42],
9+
"range": [1, 3],
10+
"rangeslider": {
11+
"yaxis": {"rangemode": "auto"}
12+
},
13+
"title": "Rangeslider Y rangemode auto"
14+
},
15+
"xaxis2": {
16+
"anchor": "y2",
17+
"domain": [0.58, 1],
18+
"range": [1.5, 3.5],
19+
"rangeslider": {
20+
"range": [-2, 4],
21+
"yaxis2": {"rangemode": "fixed", "range": [0, 10]}
22+
},
23+
"title": "Rangeslider Y2 rangemode fixed"
24+
},
25+
"yaxis": {"type": "log", "range": [2, 6], "title": "Y explicit range"},
26+
"yaxis2": {"anchor": "x2", "title": "Y2 autoranged"},
27+
"width": 700,
28+
"height": 500
29+
}
30+
}

test/jasmine/tests/axes_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1876,7 +1876,7 @@ describe('Test axes', function() {
18761876
data = [2, 5];
18771877

18781878
ax.autorange = false;
1879-
ax.rangeslider = { autorange: true };
1879+
ax._rangesliderAutorange = true;
18801880

18811881
expand(ax, data, {});
18821882
expect(ax._min).toEqual([{val: 2, pad: 0, extrapad: false}]);

0 commit comments

Comments
 (0)