Skip to content

Commit 427ffe0

Browse files
committed
frameMargins evaluated with respect to div's size
1 parent b3a4f23 commit 427ffe0

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

src/plots/plots.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1365,11 +1365,6 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
13651365
// just hide it
13661366
document.body.style.overflow = 'hidden';
13671367
}
1368-
else if(isNumeric(frameMargins) && frameMargins > 0) {
1369-
var factor = 1 - 2 * frameMargins;
1370-
newWidth = Math.round(factor * fullLayout.width);
1371-
newHeight = Math.round(factor * fullLayout.height);
1372-
}
13731368
else {
13741369
// plotly.js - let the developers do what they want, either
13751370
// provide height and width for the container div,
@@ -1379,6 +1374,12 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
13791374

13801375
newWidth = parseFloat(computedStyle.width) || parseFloat(computedStyle.maxWidth) || fullLayout.width;
13811376
newHeight = parseFloat(computedStyle.height) || parseFloat(computedStyle.maxHeight) || fullLayout.height;
1377+
1378+
if(isNumeric(frameMargins) && frameMargins > 0) {
1379+
var factor = 1 - 2 * frameMargins;
1380+
newWidth = Math.round(factor * newWidth);
1381+
newHeight = Math.round(factor * newHeight);
1382+
}
13821383
}
13831384

13841385
var minWidth = plots.layoutAttributes.width.min,

test/jasmine/tests/config_test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ describe('config argument', function() {
145145
fillFrame: false,
146146
frameMargins: 0.1
147147
};
148-
var layoutHeight = 360;
148+
var layoutHeight = Math.round(0.8 * containerHeightBeforePlot);
149149
var relayoutHeight = layoutHeight;
150150

151151
testAutosize(autosize, config, layoutHeight, relayoutHeight, done);
@@ -157,8 +157,8 @@ describe('config argument', function() {
157157
fillFrame: false,
158158
frameMargins: 0.1
159159
};
160-
var layoutHeight = 360;
161-
var relayoutHeight = 288;
160+
var layoutHeight = Math.round(0.8 * containerHeightBeforePlot);
161+
var relayoutHeight = Math.round(0.8 * containerHeightBeforeRelayout);
162162

163163
testAutosize(autosize, config, layoutHeight, relayoutHeight, done);
164164
});

0 commit comments

Comments
 (0)