From 478d42104d3cfef08b3dd81cb638913ef63e6e09 Mon Sep 17 00:00:00 2001 From: archmoj Date: Thu, 10 Dec 2020 14:11:19 -0500 Subject: [PATCH 1/4] fix issue 5290 - check before slice --- src/plot_api/plot_api.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/plot_api/plot_api.js b/src/plot_api/plot_api.js index 1cc856e3bd7..ffd6bb863b5 100644 --- a/src/plot_api/plot_api.js +++ b/src/plot_api/plot_api.js @@ -1948,7 +1948,9 @@ function axRangeSupplyDefaultsByPass(gd, flags, specs) { var axIn = gd.layout[axName]; var axOut = fullLayout[axName]; axOut.autorange = axIn.autorange; - axOut.range = axIn.range.slice(); + if(axIn.range) { + axOut.range = axIn.range.slice(); + } axOut.cleanRange(); if(axOut._matchGroup) { From 040dcd32db0db687f9598da21b2731d7d767fa26 Mon Sep 17 00:00:00 2001 From: archmoj Date: Fri, 11 Dec 2020 09:21:13 -0500 Subject: [PATCH 2/4] add jasmine test to lock issue 5290 --- test/jasmine/tests/axes_test.js | 50 +++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index 5c4cc342d1e..07ad913ce02 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -1433,6 +1433,56 @@ describe('Test axes', function() { }); }); + describe('autorange relayout', function() { + var gd; + + beforeEach(function() { + gd = createGraphDiv(); + }); + + afterEach(destroyGraphDiv); + + it('can relayout autorange', function(done) { + Plotly.newPlot(gd, { + data: [{ + x: [0, 1], + y: [0, 1] + }], + layout: { + width: 400, + height: 400, + margin: { + t: 40, + b: 40, + l: 40, + r: 40 + }, + xaxis: { + autorange: false, + }, + yaxis: { + autorange: true, + } + } + }).then(function() { + expect(gd._fullLayout.xaxis.range).toEqual([-1, 6]); + expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-0.07, 1.07]); + + Plotly.relayout(gd, 'yaxis.autorange', false); + }).then(function() { + expect(gd._fullLayout.yaxis.autorange).toBe(false); + expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-0.07, 1.07]); + + Plotly.relayout(gd, 'xaxis.autorange', true); + }).then(function() { + expect(gd._fullLayout.xaxis.autorange).toBe(true); + expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.07, 1.07]); + }) + .catch(failTest) + .then(done); + }); + }); + describe('constraints relayout', function() { var gd; From ddc1c8ab9247a546e8c879491d3bf0067b72a31a Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi <33888540+archmoj@users.noreply.github.com> Date: Fri, 11 Dec 2020 09:33:56 -0500 Subject: [PATCH 3/4] Update test/jasmine/tests/axes_test.js Co-authored-by: Alex Johnson --- test/jasmine/tests/axes_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index 07ad913ce02..05986adf9e7 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -1468,7 +1468,7 @@ describe('Test axes', function() { expect(gd._fullLayout.xaxis.range).toEqual([-1, 6]); expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-0.07, 1.07]); - Plotly.relayout(gd, 'yaxis.autorange', false); + return Plotly.relayout(gd, 'yaxis.autorange', false); }).then(function() { expect(gd._fullLayout.yaxis.autorange).toBe(false); expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-0.07, 1.07]); From 5dee4fcf7f9c406974e918467478d42a9d07f3cf Mon Sep 17 00:00:00 2001 From: Mojtaba Samimi <33888540+archmoj@users.noreply.github.com> Date: Fri, 11 Dec 2020 09:34:04 -0500 Subject: [PATCH 4/4] Update test/jasmine/tests/axes_test.js Co-authored-by: Alex Johnson --- test/jasmine/tests/axes_test.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/jasmine/tests/axes_test.js b/test/jasmine/tests/axes_test.js index 05986adf9e7..94d7979cce8 100644 --- a/test/jasmine/tests/axes_test.js +++ b/test/jasmine/tests/axes_test.js @@ -1473,7 +1473,7 @@ describe('Test axes', function() { expect(gd._fullLayout.yaxis.autorange).toBe(false); expect(gd._fullLayout.yaxis.range).toBeCloseToArray([-0.07, 1.07]); - Plotly.relayout(gd, 'xaxis.autorange', true); + return Plotly.relayout(gd, 'xaxis.autorange', true); }).then(function() { expect(gd._fullLayout.xaxis.autorange).toBe(true); expect(gd._fullLayout.xaxis.range).toBeCloseToArray([-0.07, 1.07]);