@@ -1223,7 +1223,7 @@ plots.sanitizeMargins = function(fullLayout) {
1223
1223
}
1224
1224
} ;
1225
1225
1226
- // called by legend and colorbar routines to see if we need to
1226
+ // called by components to see if we need to
1227
1227
// expand the margins to show them
1228
1228
// o is {x,l,r,y,t,b} where x and y are plot fractions,
1229
1229
// the rest are pixels in each direction
@@ -1263,7 +1263,7 @@ plots.doAutoMargin = function(gd) {
1263
1263
var gs = fullLayout . _size ,
1264
1264
oldmargins = JSON . stringify ( gs ) ;
1265
1265
1266
- // adjust margins for outside legends and colorbars
1266
+ // adjust margins for outside components
1267
1267
// fullLayout.margin is the requested margin,
1268
1268
// fullLayout._size has margins and plotsize after adjustment
1269
1269
var ml = Math . max ( fullLayout . margin . l || 0 , 0 ) ,
@@ -1273,26 +1273,37 @@ plots.doAutoMargin = function(gd) {
1273
1273
pm = fullLayout . _pushmargin ;
1274
1274
1275
1275
if ( fullLayout . margin . autoexpand !== false ) {
1276
+
1276
1277
// fill in the requested margins
1277
1278
pm . base = {
1278
1279
l : { val : 0 , size : ml } ,
1279
1280
r : { val : 1 , size : mr } ,
1280
1281
t : { val : 1 , size : mt } ,
1281
1282
b : { val : 0 , size : mb }
1282
1283
} ;
1284
+
1283
1285
// now cycle through all the combinations of l and r
1284
1286
// (and t and b) to find the required margins
1285
- Object . keys ( pm ) . forEach ( function ( k1 ) {
1287
+
1288
+ var pmKeys = Object . keys ( pm ) ;
1289
+
1290
+ for ( var i = 0 ; i < pmKeys . length ; i ++ ) {
1291
+ var k1 = pmKeys [ i ] ;
1292
+
1286
1293
var pushleft = pm [ k1 ] . l || { } ,
1287
1294
pushbottom = pm [ k1 ] . b || { } ,
1288
1295
fl = pushleft . val ,
1289
1296
pl = pushleft . size ,
1290
1297
fb = pushbottom . val ,
1291
1298
pb = pushbottom . size ;
1292
- Object . keys ( pm ) . forEach ( function ( k2 ) {
1299
+
1300
+ for ( var j = 0 ; j < pmKeys . length ; j ++ ) {
1301
+ var k2 = pmKeys [ j ] ;
1302
+
1293
1303
if ( isNumeric ( pl ) && pm [ k2 ] . r ) {
1294
1304
var fr = pm [ k2 ] . r . val ,
1295
1305
pr = pm [ k2 ] . r . size ;
1306
+
1296
1307
if ( fr > fl ) {
1297
1308
var newl = ( pl * fr +
1298
1309
( pr - fullLayout . width ) * fl ) / ( fr - fl ) ,
@@ -1304,9 +1315,11 @@ plots.doAutoMargin = function(gd) {
1304
1315
}
1305
1316
}
1306
1317
}
1318
+
1307
1319
if ( isNumeric ( pb ) && pm [ k2 ] . t ) {
1308
1320
var ft = pm [ k2 ] . t . val ,
1309
1321
pt = pm [ k2 ] . t . size ;
1322
+
1310
1323
if ( ft > fb ) {
1311
1324
var newb = ( pb * ft +
1312
1325
( pt - fullLayout . height ) * fb ) / ( ft - fb ) ,
@@ -1318,8 +1331,8 @@ plots.doAutoMargin = function(gd) {
1318
1331
}
1319
1332
}
1320
1333
}
1321
- } ) ;
1322
- } ) ;
1334
+ }
1335
+ }
1323
1336
}
1324
1337
1325
1338
gs . l = Math . round ( ml ) ;
0 commit comments