Skip to content

Commit

Permalink
Merge pull request #5336 from plotly/fix5290-autorange-false-error
Browse files Browse the repository at this point in the history
Avoid autoscale error with false autorange
  • Loading branch information
archmoj authored Dec 11, 2020
2 parents 468b759 + 5dee4fc commit 82da615
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
50 changes: 50 additions & 0 deletions test/jasmine/tests/axes_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]);

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]);

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]);
})
.catch(failTest)
.then(done);
});
});

describe('constraints relayout', function() {
var gd;

Expand Down

0 comments on commit 82da615

Please sign in to comment.