Skip to content

Commit 2d468c9

Browse files
committed
Make sure that only minimum required reserved margin is applied
1 parent e8cbfbf commit 2d468c9

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

src/plots/plots.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2011,7 +2011,7 @@ plots.doAutoMargin = function(gd) {
20112011
var oldMargins = Lib.extendFlat({}, gs);
20122012

20132013
// only account for reservedMargins if autoexpand
2014-
if(margin.autoexpand === true) {
2014+
if(margin.autoexpand !== false) {
20152015
var margins = gd._fullLayout._reservedMargin;
20162016
for(var key in margins) {
20172017
for(var side in margins[key]) {
@@ -2048,6 +2048,20 @@ plots.doAutoMargin = function(gd) {
20482048
// now cycle through all the combinations of l and r
20492049
// (and t and b) to find the required margins
20502050

2051+
// make sure that the reservedMargin is the minimum needed
2052+
for(var s in reservedMargins) {
2053+
var autoMarginPush = 0;
2054+
for(var m in pushMargin) {
2055+
if(m !== 'base') {
2056+
if(isNumeric(pushMargin[m][s].size)) {
2057+
autoMarginPush += pushMargin[m][s].size;
2058+
}
2059+
}
2060+
}
2061+
var extraMargin = Math.max(0, (margin[s] - autoMarginPush));
2062+
reservedMargins[s] = Math.max(0, reservedMargins[s] - extraMargin);
2063+
}
2064+
20512065
for(var k1 in pushMargin) {
20522066
var pushleft = pushMargin[k1].l || {};
20532067
var pushbottom = pushMargin[k1].b || {};

0 commit comments

Comments
 (0)