8000 consider init sizes from template · slawlor/plotly.js@8d64363 · GitHub
[go: up one dir, main page]

Skip to content 8000

Commit 8d64363

Browse files
committed
consider init sizes from template
1 parent 877356b commit 8d64363

File tree

1 file changed

+23
-7
lines changed

1 file changed

+23
-7
lines changed

src/plots/plots.js

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,26 @@ plots.resize = function(gd) {
8888

8989
gd._redrawTimer = setTimeout(function() {
9090
// return if there is nothing to resize or is hidden
91-
if(!gd.layout || (gd.layout.width && gd.layout.height) || Lib.isHidden(gd)) {
91+
92+
if(!gd.layout || Lib.isHidden(gd)) {
93+
resolve(gd);
94+
return;
95+
}
96+
97+
var initWidth = gd.layout.width || (gd._fullLayout._template || {}).width;
98+
var initHeight = gd.layout.height || (gd._fullLayout._template || {}).height;
99+
100+
if(initWidth && initHeight) {
92101
resolve(gd);
93102
return;
94103
}
95104

96105
delete gd.layout.width;
97106
delete gd.layout.height;
107+
if(gd.layout.template && gd.layout.template.layout) {
108+
delete gd.layout.template.layout.width;
109+
delete gd.layout.template.layout.height;
110+
}
98111

99112
// autosizing doesn't count as a change that needs saving
100113
var oldchanged = gd.changed;
@@ -1490,9 +1503,9 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
14901503
// to pass through the autosize routine
14911504
//
14921505
// This behavior is subject to change in v2.
1493-
var hasWidth = !!(layoutIn.width || (layoutOut._template || {}).width);
1494-
var hasHeight = !!(layoutIn.height || (layoutOut._template || {}).height);
1495-
coerce('autosize', !(hasWidth && hasHeight));
1506+
var initWidth = layoutIn.width || (layoutOut._template || {}).width;
1507+
var initHeight = layoutIn.height || (layoutOut._template || {}).height;
1508+
coerce('autosize', !(initWidth && initHeight));
14961509

14971510
coerce('width');
14981511
coerce('height');
@@ -1503,7 +1516,7 @@ plots.supplyLayoutGlobalDefaults = function(layoutIn, layoutOut, formatObj) {
15031516
coerce('margin.pad');
15041517
coerce('margin.autoexpand');
15051518

1506-
if(hasWidth && hasHeight) plots.sanitizeMargins(layoutOut);
1519+
if(initWidth && initHeight) plots.sanitizeMargins(layoutOut);
15071520

15081521
Registry.getComponentMethod('grid', 'sizeDefaults')(layoutIn, layoutOut);
15091522

@@ -1587,9 +1600,12 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
15871600
if(newWidth < minWidth) newWidth = minWidth;
15881601
if(newHeight < minHeight) newHeight = minHeight;
15891602

1590-
var widthHasChanged = !layout.width &&
1603+
var initWidth = layout.width || (fullLayout._template || {}).width;
1604+
var initHeight = layout.height || (fullLayout._template || {}).height;
1605+
1606+
var widthHasChanged = !initWidth &&
15911607
(Math.abs(fullLayout.width - newWidth) > 1);
1592-
var heightHasChanged = !layout.height &&
1608+
var heightHasChanged = !initHeight &&
15931609
(Math.abs(fullLayout.height - newHeight) > 1);
15941610

15951611
if(heightHasChanged || widthHasChanged) {

0 commit comments

Comments
 (0)
0