Skip to content

Commit 30a692e

Browse files
committed
do not accept partial ranges if autorange is set to true
1 parent 7776305 commit 30a692e

File tree

3 files changed

+13
-12
lines changed

3 files changed

+13
-12
lines changed

src/plots/cartesian/axis_defaults.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,25 +95,25 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
9595
coerce('minallowed');
9696
coerce('maxallowed');
9797
var range = coerce('range');
98-
9998
var autorangeDflt = containerOut.getAutorangeDflt(range, options);
10099
var autorange = coerce('autorange', autorangeDflt);
101-
var autorangeTrue;
100+
101+
var shouldAutorange;
102102

103103
// validate range and set autorange true for invalid partial ranges
104104
if(range && (
105105
(range[0] === null && range[1] === null) ||
106-
((range[0] === null || range[1] === null) && autorange === 'reversed') ||
106+
((range[0] === null || range[1] === null) && (autorange === 'reversed' || autorange === true)) ||
107107
(range[0] !== null && (autorange === 'min' || autorange === 'max reversed')) ||
108108
(range[1] !== null && (autorange === 'max' || autorange === 'min reversed'))
109109
)) {
110110
range = undefined;
111111
delete containerOut.range;
112112
containerOut.autorange = true;
113-
autorangeTrue = true;
113+
shouldAutorange = true;
114114
}
115115

116-
if(!autorangeTrue) {
116+
if(!shouldAutorange) {
117117
autorangeDflt = containerOut.getAutorangeDflt(range, options);
118118
autorange = coerce('autorange', autorangeDflt);
119119
}

src/plots/polar/layout_defaults.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,25 +80,24 @@ function handleDefaults(contIn, contOut, coerce, opts) {
8080
coerceAxis('minallowed');
8181
coerceAxis('maxallowed');
8282
var range = coerceAxis('range');
83-
8483
var autorangeDflt = axOut.getAutorangeDflt(range);
8584
var autorange = coerceAxis('autorange', autorangeDflt);
86-
var autorangeTrue;
85+
var shouldAutorange;
8786

8887
// validate range and set autorange true for invalid partial ranges
8988
if(range && (
9089
(range[0] === null && range[1] === null) ||
91-
((range[0] === null || range[1] === null) && autorange === 'reversed') ||
90+
((range[0] === null || range[1] === null) && (autorange === 'reversed' || autorange === true)) ||
9291
(range[0] !== null && (autorange === 'min' || autorange === 'max reversed')) ||
9392
(range[1] !== null && (autorange === 'max' || autorange === 'min reversed'))
9493
)) {
9594
range = undefined;
9695
delete axOut.range;
9796
axOut.autorange = true;
98-
autorangeTrue = true;
97+
shouldAutorange = true;
9998
}
10099

101-
if(!autorangeTrue) {
100+
if(!shouldAutorange) {
102101
autorangeDflt = axOut.getAutorangeDflt(range);
103102
autorange = coerceAxis('autorange', autorangeDflt);
104103
}

test/jasmine/tests/axes_test.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -729,9 +729,11 @@ describe('Test axes', function() {
729729
yaxis7: { range: [null, 2], autorange: 'min reversed' }, // first range is null not second
730730
yaxis8: { range: [1, null], autorange: 'reversed' },
731731
yaxis9: { range: [null, 2], autorange: 'reversed' },
732+
yaxis10: { range: [1, null], autorange: true },
733+
yaxis11: { range: [null, 2], autorange: true },
732734
};
733-
layoutOut._subplots.cartesian.push('x2y2', 'xy3', 'x3y4', 'x3y5', 'x3y6', 'x3y7', 'x3y9', 'x3y9');
734-
layoutOut._subplots.yaxis.push('x2', 'x3', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9');
735+
layoutOut._subplots.cartesian.push('x2y2', 'xy3', 'x3y4', 'x3y5', 'x3y6', 'x3y7', 'x3y9', 'x3y9', 'x3y10', 'x3y11');
736+
layoutOut._subplots.yaxis.push('x2', 'x3', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9', 'y10', 'y11');
735737

736738
supplyLayoutDefaults(layoutIn, layoutOut, fullData);
737739

0 commit comments

Comments
 (0)