From 21a605d816947ed39bb4c1d94c21b8df50c251c7 Mon Sep 17 00:00:00 2001 From: sap1110 <238814652+sap1110@users.noreply.github.com> Date: Mon, 28 Sep 2026 13:53:54 +0530 Subject: [PATCH 1/2] Keep autorange on matched axes when only another group sets a range The match group defaults kept the hasRange flag across groups. After one group with a set range, every later group without a range got autorange false, and its axes fell back to the default [-1, 4] range. A 2x2 grid with shared x and y axes and a set x range shows the problem. Reset the flag for each group. Read the range from the axis that supplied the value, because the loop variable holds the last axis of the group, which can differ from the axis with the range. Fixes #8053 --- draftlogs/XXXX_fix.md | 1 + src/plots/cartesian/constraints.js | 13 +++++++++---- test/jasmine/tests/axes_test.js | 28 ++++++++++++++++++++++++++++ 3 files changed, 38 insertions(+), 4 deletions(-) create mode 100644 draftlogs/XXXX_fix.md diff --git a/draftlogs/XXXX_fix.md b/draftlogs/XXXX_fix.md new file mode 100644 index 00000000000..6b96136431b --- /dev/null +++ b/draftlogs/XXXX_fix.md @@ -0,0 +1 @@ +- Fix autorange turning off for matched axes that have no set range, when another match group sets a range [[#XXXX](https://github.com/plotly/plotly.js/pull/XXXX)] diff --git a/src/plots/cartesian/constraints.js b/src/plots/cartesian/constraints.js index 2dd1e665df1..f2d71564bbe 100644 --- a/src/plots/cartesian/constraints.js +++ b/src/plots/cartesian/constraints.js @@ -105,9 +105,13 @@ exports.handleDefaults = function(layoutIn, layoutOut, opts) { ]; var hasRange = false; var hasDayOfWeekBreaks = false; + var rangeIn; function setAttrVal() { val = axOut[attr]; + if(attr === 'range') { + rangeIn = axIn.range; + } if(attr === 'rangebreaks') { hasDayOfWeekBreaks = axOut._hasDayOfWeekBreaks; } @@ -115,6 +119,7 @@ exports.handleDefaults = function(layoutIn, layoutOut, opts) { for(i = 0; i < matchGroups.length; i++) { group = matchGroups[i]; + hasRange = false; // find 'matching' range attrs for(var j = 0; j < matchAttrs.length; j++) { @@ -146,10 +151,10 @@ exports.handleDefaults = function(layoutIn, layoutOut, opts) { // if nobody explicitly specifies autorange, but someone does // explicitly specify range, autorange must be disabled. if(attr === 'range' && val && - axIn.range && - axIn.range.length === 2 && - axIn.range[0] !== null && - axIn.range[1] !== null + rangeIn && + rangeIn.length === 2 && + rangeIn[0] !== null && + rangeIn[1] !== null ) { hasRange = true; } diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index e964c3c33da..0d8d68dd18f 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -1187,6 +1187,34 @@ describe('Test axes', function() { _assertMatchingAxes(['xaxis4', 'yaxis4'], false, [-1, 3]); }); + it('should not turn off autorange in match groups that have no set range', function() { + // shared x and y axes on a 2x2 grid, with a range on every x axis + layoutIn = { + xaxis: {matches: 'x3', range: [0, 100]}, + xaxis2: {matches: 'x4', range: [0, 100]}, + xaxis3: {range: [0, 100]}, + xaxis4: {range: [0, 100]}, + yaxis: {}, + yaxis2: {matches: 'y'}, + yaxis3: {}, + yaxis4: {matches: 'y3'} + }; + layoutOut._subplots.cartesian.push('x2y2', 'x3y3', 'x4y4'); + layoutOut._subplots.xaxis.push('x2', 'x3', 'x4'); + layoutOut._subplots.yaxis.push('y2', 'y3', 'y4'); + + supplyLayoutDefaults(layoutIn, layoutOut, fullData); + + expect(layoutOut._axisMatchGroups.length).toBe(4); + + ['xaxis', 'xaxis2', 'xaxis3', 'xaxis4'].forEach((axName) => { + expect(layoutOut[axName].autorange).withContext(axName).toBe(false); + }); + ['yaxis', 'yaxis2', 'yaxis3', 'yaxis4'].forEach((axName) => { + expect(layoutOut[axName].autorange).withContext(axName).toBe(true); + }); + }); + it('should match set axis range value for matching axes even when matching a *missing* axis', function() { layoutIn = { // N.B. xaxis is set, but does not correspond to a subplot From dcdcf14703377a9b59dd4212c154e40d6d804357 Mon Sep 17 00:00:00 2001 From: sap1110 <238814652+sap1110@users.noreply.github.com> Date: Tue, 29 Sep 2026 18:24:00 +0530 Subject: [PATCH 2/2] Add draftlog for #8092 --- draftlogs/{XXXX_fix.md => 8092_fix.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename draftlogs/{XXXX_fix.md => 8092_fix.md} (100%) diff --git a/draftlogs/XXXX_fix.md b/draftlogs/8092_fix.md similarity index 100% rename from draftlogs/XXXX_fix.md rename to draftlogs/8092_fix.md