Skip to content

Commit 8396018

Browse files
committed
try less hacky solution for relayout(gd, 'width', null)
1 parent 4c14251 commit 8396018

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/plot_api/plot_api.js

+7-3
Original file line numberDiff line numberDiff line change
@@ -1821,10 +1821,14 @@ function _relayout(gd, aobj) {
18211821
// op and has no flag.
18221822
undoit[ai] = (pleaf === 'reverse') ? vi : p.get();
18231823

1824-
// tweak width / height update value when null such that
1825-
// new dimensions are honored in Plots.supplyDefaults
1824+
// Setting width or height to null must reset the graph's width / height
1825+
// back to its initial value as listed in attribute declaration.
1826+
//
1827+
// We must manually set them back here, because we can't rely on
1828+
// Plots.plotAutoSize as it falls back to computing width / height values
1829+
// from the DOM which can have been changed by other relayout calls.
18261830
if(['width', 'height'].indexOf(ai) !== -1 && vi === null) {
1827-
vi = 'initial';
1831+
gd._fullLayout[ai] = Plots.layoutAttributes[ai].dflt;
18281832
}
18291833
// check autorange vs range
18301834
else if(pleafPlus.match(/^[xyz]axis[0-9]*\.range(\[[0|1]\])?$/)) {

0 commit comments

Comments
 (0)