Skip to content

Bugfix: Only add minimum margin-spacing for container referenced components #6616

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Jun 1, 2023
Prev Previous commit
Next Next commit
Clean code
  • Loading branch information
hannahker committed May 30, 2023
commit 3c70b49bae00221b54cc7fbecf182fce83cf2194
23 changes: 10 additions & 13 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -2010,16 +2010,6 @@ plots.doAutoMargin = function(gd) {
var reservedMargins = {t: 0, b: 0, l: 0, r: 0};
var oldMargins = Lib.extendFlat({}, gs);

// only account for reservedMargins if autoexpand
if(margin.autoexpand !== false) {
var margins = gd._fullLayout._reservedMargin;
for(var key in margins) {
for(var side in margins[key]) {
var val = margins[key][side];
reservedMargins[side] = Math.max(reservedMargins[side], val);
}
}
}
// adjust margins for outside components
// fullLayout.margin is the requested margin,
// fullLayout._size has margins and plotsize after adjustment
Expand All @@ -2032,11 +2022,18 @@ plots.doAutoMargin = function(gd) {
var minreducedwidth = fullLayout.minreducedwidth;
var minreducedheight = fullLayout.minreducedheight;

if(fullLayout.margin.autoexpand !== false) {
if(margin.autoexpand !== false) {
for(var k in pushMargin) {
if(!pushMarginIds[k]) delete pushMargin[k];
}

var margins = gd._fullLayout._reservedMargin;
for(var key in margins) {
for(var side in margins[key]) {
var val = margins[key][side];
reservedMargins[side] = Math.max(reservedMargins[side], val);
}
}
// fill in the requested margins
pushMargin.base = {
l: {val: 0, size: ml},
Expand All @@ -2045,8 +2042,6 @@ plots.doAutoMargin = function(gd) {
b: {val: 0, size: mb}
};

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

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

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