Skip to content

Commit

Permalink
do not accept partial ranges if autorange is set to true
Browse files Browse the repository at this point in the history
  • Loading branch information
archmoj committed Aug 24, 2023
1 parent 7776305 commit 30a692e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
10 changes: 5 additions & 5 deletions src/plots/cartesian/axis_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,25 +95,25 @@ module.exports = function handleAxisDefaults(containerIn, containerOut, coerce,
coerce('minallowed');
coerce('maxallowed');
var range = coerce('range');

var autorangeDflt = containerOut.getAutorangeDflt(range, options);
var autorange = coerce('autorange', autorangeDflt);
var autorangeTrue;

var shouldAutorange;

// validate range and set autorange true for invalid partial ranges
if(range && (
(range[0] === null && range[1] === null) ||
((range[0] === null || range[1] === null) && autorange === 'reversed') ||
((range[0] === null || range[1] === null) && (autorange === 'reversed' || autorange === true)) ||
(range[0] !== null && (autorange === 'min' || autorange === 'max reversed')) ||
(range[1] !== null && (autorange === 'max' || autorange === 'min reversed'))
)) {
range = undefined;
delete containerOut.range;
containerOut.autorange = true;
autorangeTrue = true;
shouldAutorange = true;
}

if(!autorangeTrue) {
if(!shouldAutorange) {
autorangeDflt = containerOut.getAutorangeDflt(range, options);
autorange = coerce('autorange', autorangeDflt);
}
Expand Down
9 changes: 4 additions & 5 deletions src/plots/polar/layout_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,24 @@ function handleDefaults(contIn, contOut, coerce, opts) {
coerceAxis('minallowed');
coerceAxis('maxallowed');
var range = coerceAxis('range');

var autorangeDflt = axOut.getAutorangeDflt(range);
var autorange = coerceAxis('autorange', autorangeDflt);
var autorangeTrue;
var shouldAutorange;

// validate range and set autorange true for invalid partial ranges
if(range && (
(range[0] === null && range[1] === null) ||
((range[0] === null || range[1] === null) && autorange === 'reversed') ||
((range[0] === null || range[1] === null) && (autorange === 'reversed' || autorange === true)) ||
(range[0] !== null && (autorange === 'min' || autorange === 'max reversed')) ||
(range[1] !== null && (autorange === 'max' || autorange === 'min reversed'))
)) {
range = undefined;
delete axOut.range;
axOut.autorange = true;
autorangeTrue = true;
shouldAutorange = true;
}

if(!autorangeTrue) {
if(!shouldAutorange) {
autorangeDflt = axOut.getAutorangeDflt(range);
autorange = coerceAxis('autorange', autorangeDflt);
}
Expand Down
6 changes: 4 additions & 2 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,9 +729,11 @@ describe('Test axes', function() {
yaxis7: { range: [null, 2], autorange: 'min reversed' }, // first range is null not second
yaxis8: { range: [1, null], autorange: 'reversed' },
yaxis9: { range: [null, 2], autorange: 'reversed' },
yaxis10: { range: [1, null], autorange: true },
yaxis11: { range: [null, 2], autorange: true },
};
layoutOut._subplots.cartesian.push('x2y2', 'xy3', 'x3y4', 'x3y5', 'x3y6', 'x3y7', 'x3y9', 'x3y9');
layoutOut._subplots.yaxis.push('x2', 'x3', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9');
layoutOut._subplots.cartesian.push('x2y2', 'xy3', 'x3y4', 'x3y5', 'x3y6', 'x3y7', 'x3y9', 'x3y9', 'x3y10', 'x3y11');
layoutOut._subplots.yaxis.push('x2', 'x3', 'y2', 'y3', 'y4', 'y5', 'y6', 'y7', 'y8', 'y9', 'y10', 'y11');

supplyLayoutDefaults(layoutIn, layoutOut, fullData);

Expand Down

0 comments on commit 30a692e

Please sign in to comment.