Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
assure that clearing cartesian axes in relayout lead to a re-calc
  • Loading branch information
etpinard committed Feb 26, 2016
commit 3a680233a615cba2679c14f99ac7df10aca93eb2
4 changes: 4 additions & 0 deletions src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -2172,6 +2172,10 @@ Plotly.relayout = function relayout(gd, astr, val) {
else if(pleaf === 'tickmode') {
doextra([ptrunk + '.tick0', ptrunk + '.dtick'], undefined);
}
else if(/[xy]axis[0-9]*?$/.test(pleaf) && !Object.keys(vi || {}).length) {
docalc = true;
}

// toggling log without autorange: need to also recalculate ranges
// logical XOR (ie are we toggling log)
if(pleaf==='type' && ((parentFull.type === 'log') !== (vi === 'log'))) {
Expand Down
35 changes: 34 additions & 1 deletion test/jasmine/tests/plot_interact_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ describe('Test plot structure', function() {

beforeEach(function(done) {
gd = createGraphDiv();
Plotly.plot(gd, mock.data, mock.layout).then(done);

var mockData = Lib.extendDeep([], mock.data),
mockLayout = Lib.extendDeep({}, mock.layout);

Plotly.plot(gd, mockData, mockLayout).then(done);
});

it('has one *subplot xy* node', function() {
Expand Down Expand Up @@ -91,6 +95,35 @@ describe('Test plot structure', function() {
done();
});
});

it('should restore layout axes when they get deleted', function(done) {
expect(countScatterTraces()).toEqual(mock.data.length);
expect(countSubplots()).toEqual(1);

Plotly.relayout(gd, {xaxis: null, yaxis: null}).then(function() {
expect(countScatterTraces()).toEqual(1);
expect(countSubplots()).toEqual(1);

return Plotly.relayout(gd, 'xaxis', null);
}).then(function() {
expect(countScatterTraces()).toEqual(1);
expect(countSubplots()).toEqual(1);

return Plotly.relayout(gd, 'xaxis', {});
}).then(function() {
expect(countScatterTraces()).toEqual(1);
expect(countSubplots()).toEqual(1);

return Plotly.relayout(gd, 'yaxis', null);
}).then(function() {
expect(countScatterTraces()).toEqual(1);
expect(countSubplots()).toEqual(1);

return Plotly.relayout(gd, 'yaxis', {});
}).then(function() {
expect(countScatterTraces()).toEqual(1);
expect(countSubplots()).toEqual(1);

done();
});
});
Expand Down