Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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