Skip to content

Commit 670d238

Browse files
committed
reduce large margins on both sides by a ratio instead of setting them to zero
1 parent 28fc880 commit 670d238

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/plots/plots.js

+10-6
Original file line numberDiff line numberDiff line change
@@ -1906,13 +1906,17 @@ plots.autoMargin = function(gd, id, o) {
19061906

19071907
// if the item is too big, just give it enough automargin to
19081908
// make sure you can still grab it and bring it back
1909-
if(o.l + o.r > minFinalWidth) {
1910-
Lib.log('Margin push', id, 'is too big in x, dropping');
1911-
o.l = o.r = 0;
1909+
var rW = (o.l + o.r) / minFinalWidth;
1910+
if(rW > 1) {
1911+
Lib.log('Margin push', id, 'is too big in x, adjusting');
1912+
o.l /= rW;
1913+
o.r /= rW;
19121914
}
1913-
if(o.b + o.t > minFinalHeight) {
1914-
Lib.log('Margin push', id, 'is too big in y, dropping');
1915-
o.b = o.t = 0;
1915+
var rH = (o.t + o.b) / minFinalHeight;
1916+
if(rH > 1) {
1917+
Lib.log('Margin push', id, 'is too big in y, adjusting');
1918+
o.t /= rH;
1919+
o.b /= rH;
19161920
}
19171921

19181922
var xl = o.xl !== undefined ? o.xl : o.x;
Loading

0 commit comments

Comments
 (0)