Skip to content

Commit 3c70b49

Browse files
committed
Clean code
1 parent ba410a8 commit 3c70b49

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

src/plots/plots.js

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2010,16 +2010,6 @@ plots.doAutoMargin = function(gd) {
20102010
var reservedMargins = {t: 0, b: 0, l: 0, r: 0};
20112011
var oldMargins = Lib.extendFlat({}, gs);
20122012

2013-
// only account for reservedMargins if autoexpand
2014-
if(margin.autoexpand !== false) {
2015-
var margins = gd._fullLayout._reservedMargin;
2016-
for(var key in margins) {
2017-
for(var side in margins[key]) {
2018-
var val = margins[key][side];
2019-
reservedMargins[side] = Math.max(reservedMargins[side], val);
2020-
}
2021-
}
2022-
}
20232013
// adjust margins for outside components
20242014
// fullLayout.margin is the requested margin,
20252015
// fullLayout._size has margins and plotsize after adjustment
@@ -2032,11 +2022,18 @@ plots.doAutoMargin = function(gd) {
20322022
var minreducedwidth = fullLayout.minreducedwidth;
20332023
var minreducedheight = fullLayout.minreducedheight;
20342024

2035-
if(fullLayout.margin.autoexpand !== false) {
2025+
if(margin.autoexpand !== false) {
20362026
for(var k in pushMargin) {
20372027
if(!pushMarginIds[k]) delete pushMargin[k];
20382028
}
20392029

2030+
var margins = gd._fullLayout._reservedMargin;
2031+
for(var key in margins) {
2032+
for(var side in margins[key]) {
2033+
var val = margins[key][side];
2034+
reservedMargins[side] = Math.max(reservedMargins[side], val);
2035+
}
2036+
}
20402037
// fill in the requested margins
20412038
pushMargin.base = {
20422039
l: {val: 0, size: ml},
@@ -2045,8 +2042,6 @@ plots.doAutoMargin = function(gd) {
20452042
b: {val: 0, size: mb}
20462043
};
20472044

2048-
// now cycle through all the combinations of l and r
2049-
// (and t and b) to find the required margins
20502045

20512046
// make sure that the reservedMargin is the minimum needed
20522047
for(var s in reservedMargins) {
@@ -2062,6 +2057,8 @@ plots.doAutoMargin = function(gd) {
20622057
reservedMargins[s] = Math.max(0, reservedMargins[s] - extraMargin);
20632058
}
20642059

2060+
// now cycle through all the combinations of l and r
2061+
// (and t and b) to find the required margins
20652062
for(var k1 in pushMargin) {
20662063
var pushleft = pushMargin[k1].l || {};
20672064
var pushbottom = pushMargin[k1].b || {};

0 commit comments

Comments
 (0)