Skip to content

Commit ba6eeea

Browse files
committed
assure that clearing cartesian axes in relayout lead to a re-calc
1 parent a2f2ce8 commit ba6eeea

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

src/plot_api/plot_api.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2161,6 +2161,10 @@ Plotly.relayout = function relayout(gd, astr, val) {
21612161
else if(pleaf === 'tickmode') {
21622162
doextra([ptrunk + '.tick0', ptrunk + '.dtick'], undefined);
21632163
}
2164+
else if(/[xy]axis[0-9]*?$/.test(pleaf) && !Object.keys(vi || {}).length) {
2165+
docalc = true;
2166+
}
2167+
21642168
// toggling log without autorange: need to also recalculate ranges
21652169
// logical XOR (ie are we toggling log)
21662170
if(pleaf==='type' && ((parentFull.type === 'log') !== (vi === 'log'))) {

test/jasmine/tests/plot_interact_test.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ describe('Test plot structure', function() {
3939

4040
beforeEach(function(done) {
4141
gd = createGraphDiv();
42-
Plotly.plot(gd, mock.data, mock.layout).then(done);
42+
43+
var mockData = Lib.extendDeep([], mock.data),
44+
mockLayout = Lib.extendDeep({}, mock.layout);
45+
46+
Plotly.plot(gd, mockData, mockLayout).then(done);
4347
});
4448

4549
it('has one *subplot xy* node', function() {
@@ -91,6 +95,35 @@ describe('Test plot structure', function() {
9195
done();
9296
});
9397
});
98+
99+
it('should restore layout axes when they get deleted', function(done) {
100+
expect(countScatterTraces()).toEqual(mock.data.length);
101+
expect(countSubplots()).toEqual(1);
102+
103+
Plotly.relayout(gd, {xaxis: null, yaxis: null}).then(function() {
104+
expect(countScatterTraces()).toEqual(1);
105+
expect(countSubplots()).toEqual(1);
106+
107+
return Plotly.relayout(gd, 'xaxis', null);
108+
}).then(function() {
109+
expect(countScatterTraces()).toEqual(1);
110+
expect(countSubplots()).toEqual(1);
111+
112+
return Plotly.relayout(gd, 'xaxis', {});
113+
}).then(function() {
114+
expect(countScatterTraces()).toEqual(1);
115+
expect(countSubplots()).toEqual(1);
116+
117+
return Plotly.relayout(gd, 'yaxis', null);
118+
}).then(function() {
119+
expect(countScatterTraces()).toEqual(1);
120+
expect(countSubplots()).toEqual(1);
121+
122+
return Plotly.relayout(gd, 'yaxis', {});
123+
}).then(function() {
124+
expect(countScatterTraces()).toEqual(1);
125+
expect(countSubplots()).toEqual(1);
126+
94127
done();
95128
});
96129
});

0 commit comments

Comments
 (0)