From 30a692e1d1bf3eb3a6a8266011b11b570606e43a Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi Date: Thu, 24 Aug 2023 10:48:35 -0400 Subject: [PATCH] do not accept partial ranges if autorange is set to true --- src/plots/cartesian/axis_defaults.js | 10 +++++----- src/plots/polar/layout_defaults.js | 9 ++++----- test/jasmine/tests/axes_test.js | 6 ++++-- 3 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/plots/cartesian/axis_defaults.js b/src/plots/cartesian/axis_defaults.js index 0bff1ab3596..fbfcbe41233 100644 --- a/src/plots/cartesian/axis_defaults.js +++ b/src/plots/cartesian/axis_defaults.js @@ -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); } diff --git a/src/plots/polar/layout_defaults.js b/src/plots/polar/layout_defaults.js index 82acb809b26..25dd745851d 100644 --- a/src/plots/polar/layout_defaults.js +++ b/src/plots/polar/layout_defaults.js @@ -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); } diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index 231a2b35f32..8b65344e5bb 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -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);