Skip to content

Commit 77971f4

Browse files
committed
make sure relayout(gd, 'width', null) resets width to default
1 parent b335b05 commit 77971f4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

src/plot_api/plot_api.js

+6-1
Original file line numberDiff line numberDiff line change
@@ -1803,8 +1803,13 @@ function _relayout(gd, aobj) {
18031803
// op and has no flag.
18041804
undoit[ai] = (pleaf === 'reverse') ? vi : p.get();
18051805

1806+
// tweak width / height update value when null such that
1807+
// new dimensions are honored in Plots.supplyDefaults
1808+
if(['width', 'height'].indexOf(ai) !== -1 && vi === null) {
1809+
vi = 'initial';
1810+
}
18061811
// check autorange vs range
1807-
if(pleafPlus.match(/^[xyz]axis[0-9]*\.range(\[[0|1]\])?$/)) {
1812+
else if(pleafPlus.match(/^[xyz]axis[0-9]*\.range(\[[0|1]\])?$/)) {
18081813
doextra(ptrunk + '.autorange', false);
18091814
}
18101815
else if(pleafPlus.match(/^[xyz]axis[0-9]*\.autorange$/)) {

src/plots/plots.js

+4
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ function positionPlayWithData(gd, container) {
307307
});
308308
}
309309
}
310+
310311
plots.sendDataToCloud = function(gd) {
311312
gd.emit('plotly_beforeexport');
312313

@@ -372,6 +373,7 @@ plots.supplyDefaults = function(gd) {
372373
// because fullData needs a few things from layout
373374

374375
if(oldFullLayout._initialAutoSizeIsDone) {
376+
375377
// coerce the updated layout while preserving width and height
376378
var oldWidth = oldFullLayout.width,
377379
oldHeight = oldFullLayout.height;
@@ -382,13 +384,15 @@ plots.supplyDefaults = function(gd) {
382384
if(!newLayout.height) newFullLayout.height = oldHeight;
383385
}
384386
else {
387+
385388
// coerce the updated layout and autosize if needed
386389
plots.supplyLayoutGlobalDefaults(newLayout, newFullLayout);
387390

388391
var missingWidthOrHeight = (!newLayout.width || !newLayout.height),
389392
autosize = newFullLayout.autosize,
390393
autosizable = gd._context && gd._context.autosizable,
391394
initialAutoSize = missingWidthOrHeight && (autosize || autosizable);
395+
392396
if(initialAutoSize) plots.plotAutoSize(gd, newLayout, newFullLayout);
393397
else if(missingWidthOrHeight) plots.sanitizeMargins(gd);
394398

0 commit comments

Comments
 (0)