Skip to content

Commit f4ca110

Browse files
committed
plots: relink subplot before relink _ keys in fullLayout
- so that old axis scale fields (e.g _length, _m, ...) in fullLayout don't get relinked in subplot objects, leading to incorrect relayout / resize.
1 parent c4efa80 commit f4ca110

File tree

2 files changed

+15
-4
lines changed

2 files changed

+15
-4
lines changed

src/plots/plots.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ plots.supplyDefaults = function(gd) {
402402
// clean subplots and other artifacts from previous plot calls
403403
plots.cleanPlot(newFullData, newFullLayout, oldFullData, oldFullLayout);
404404

405+
// relink / initialize subplot axis objects
406+
plots.linkSubplots(newFullData, newFullLayout, oldFullData, oldFullLayout);
407+
405408
// relink functions and _ attributes to promote consistency between plots
406409
relinkPrivateKeys(newFullLayout, oldFullLayout);
407410

@@ -416,9 +419,6 @@ plots.supplyDefaults = function(gd) {
416419
ax.setScale();
417420
}
418421

419-
// relink / initialize subplot axis objects
420-
plots.linkSubplots(newFullData, newFullLayout, oldFullData, oldFullLayout);
421-
422422
// update object references in calcdata
423423
if((gd.calcdata || []).length === newFullData.length) {
424424
for(i = 0; i < newFullData.length; i++) {

test/jasmine/tests/plots_test.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,7 @@ describe('Test Plots', function() {
248248
describe('Plots.resize', function() {
249249
var gd;
250250

251-
beforeEach(function(done) {
251+
beforeAll(function(done) {
252252
gd = createGraphDiv();
253253

254254
Plotly.plot(gd, [{ x: [1, 2, 3], y: [2, 3, 4] }], {})
@@ -287,6 +287,17 @@ describe('Test Plots', function() {
287287
expect(svgHeight).toBe(400);
288288
}
289289
});
290+
291+
it('should update the axis scales', function() {
292+
var fullLayout = gd._fullLayout,
293+
plotinfo = fullLayout._plots.xy;
294+
295+
expect(fullLayout.xaxis._length).toEqual(240);
296+
expect(fullLayout.yaxis._length).toEqual(220);
297+
298+
expect(plotinfo.xaxis._length).toEqual(240);
299+
expect(plotinfo.yaxis._length).toEqual(220);
300+
});
290301
});
291302

292303
describe('Plots.purge', function() {

0 commit comments

Comments
 (0)