Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 43aa683

Browse files
committed
apply Alex's suggestion
1 parent a814965 commit 43aa683

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

src/plots/plots.js

Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1866,8 +1866,13 @@ function initMargins(fullLayout) {
18661866
if(!fullLayout._pushmarginIds) fullLayout._pushmarginIds = {};
18671867
}
18681868

1869-
var MIN_FINAL_WIDTH = 64; // could possibly be exposed as layout.margin.minfinalwidth
1870-
var MIN_FINAL_HEIGHT = 16; // could possibly be exposed as layout.margin.minfinalheight
1869+
// non-negotiable - this is the smallest height we will allow users to specify via explicit margins
1870+
var MIN_SPECIFIED_WIDTH = 2;
1871+
var MIN_SPECIFIED_HEIGHT = 2;
1872+
1873+
// could be exposed as an option - the smallest we will allow automargin to shrink a larger plot
1874+
var MIN_REDUCED_WIDTH = 64;
1875+
var MIN_REDUCED_HEIGHT = 64;
18711876

18721877
/**
18731878
* autoMargin: called by components that may need to expand the margins to
@@ -1890,8 +1895,20 @@ plots.autoMargin = function(gd, id, o) {
18901895
var height = fullLayout.height;
18911896
var margin = fullLayout.margin;
18921897

1893-
var maxSpaceW = Math.max(0, width - MIN_FINAL_WIDTH);
1894-
var maxSpaceH = Math.max(0, height - MIN_FINAL_HEIGHT);
1898+
var minFinalWidth = Lib.constrain(
1899+
width - margin.l - margin.r,
1900+
MIN_SPECIFIED_WIDTH,
1901+
MIN_REDUCED_WIDTH
1902+
);
1903+
1904+
var minFinalHeight = Lib.constrain(
1905+
height - margin.t - margin.b,
1906+
MIN_SPECIFIED_HEIGHT,
1907+
MIN_REDUCED_HEIGHT
1908+
);
1909+
1910+
var maxSpaceW = Math.max(0, width - minFinalWidth);
1911+
var maxSpaceH = Math.max(0, height - minFinalHeight);
18951912

18961913
var pushMargin = fullLayout._pushmargin;
18971914
var pushMarginIds = fullLayout._pushmarginIds;
@@ -2021,8 +2038,20 @@ plots.doAutoMargin = function(gd) {
20212038
}
20222039
}
20232040

2024-
var maxSpaceW = Math.max(0, width - MIN_FINAL_WIDTH);
2025-
var maxSpaceH = Math.max(0, height - MIN_FINAL_HEIGHT);
2041+
var minFinalWidth = Lib.constrain(
2042+
width - margin.l - margin.r,
2043+
MIN_SPECIFIED_WIDTH,
2044+
MIN_REDUCED_WIDTH
2045+
);
2046+
2047+
var minFinalHeight = Lib.constrain(
2048+
height - margin.t - margin.b,
2049+
MIN_SPECIFIED_HEIGHT,
2050+
MIN_REDUCED_HEIGHT
2051+
);
2052+
2053+
var maxSpaceW = Math.max(0, width - minFinalWidth);
2054+
var maxSpaceH = Math.max(0, height - minFinalHeight);
20262055

20272056
if(maxSpaceW) {
20282057
var rW = (ml + mr) / maxSpaceW;
354 Bytes
Loading
Loading

0 commit comments

Comments
 (0)