Skip to content

Commit b3a4f23

Browse files
committed
🔪 calculatedReserverdMargins
1 parent 95d67ea commit b3a4f23

File tree

1 file changed

+3
-35
lines changed

1 file changed

+3
-35
lines changed

src/plots/plots.js

+3-35
Original file line numberDiff line numberDiff line change
@@ -1366,18 +1366,9 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
13661366
document.body.style.overflow = 'hidden';
13671367
}
13681368
else if(isNumeric(frameMargins) && frameMargins > 0) {
1369-
var reservedMargins = calculateReservedMargins(gd._boundingBoxMargins),
1370-
reservedWidth = reservedMargins.left + reservedMargins.right,
1371-
reservedHeight = reservedMargins.bottom + reservedMargins.top,
1372-
factor = 1 - 2 * frameMargins;
1373-
1374-
var gdBB = {
1375-
width: fullLayout.width,
1376-
height: fullLayout.height
1377-
};
1378-
1379-
newWidth = Math.round(factor * (gdBB.width - reservedWidth));
1380-
newHeight = Math.round(factor * (gdBB.height - reservedHeight));
1369+
var factor = 1 - 2 * frameMargins;
1370+
newWidth = Math.round(factor * fullLayout.width);
1371+
newHeight = Math.round(factor * fullLayout.height);
13811372
}
13821373
else {
13831374
// plotly.js - let the developers do what they want, either
@@ -1414,29 +1405,6 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
14141405
plots.sanitizeMargins(fullLayout);
14151406
};
14161407

1417-
/**
1418-
* Reduce all reserved margin objects to a single required margin reservation.
1419-
*
1420-
* @param {Object} margins
1421-
* @returns {{left: number, right: number, bottom: number, top: number}}
1422-
*/
1423-
function calculateReservedMargins(margins) {
1424-
var resultingMargin = {left: 0, right: 0, bottom: 0, top: 0},
1425-
marginName;
1426-
1427-
if(margins) {
1428-
for(marginName in margins) {
1429-
if(margins.hasOwnProperty(marginName)) {
1430-
resultingMargin.left += margins[marginName].left || 0;
1431-
resultingMargin.right += margins[marginName].right || 0;
1432-
resultingMargin.bottom += margins[marginName].bottom || 0;
1433-
resultingMargin.top += margins[marginName].top || 0;
1434-
}
1435-
}
1436-
}
1437-
return resultingMargin;
1438-
}
1439-
14401408
plots.supplyLayoutModuleDefaults = function(layoutIn, layoutOut, fullData, transitionData) {
14411409
var componentsRegistry = Registry.componentsRegistry;
14421410
var basePlotModules = layoutOut._basePlotModules;

0 commit comments

Comments
 (0)