Skip to content

Commit 4b52e42

Browse files
authored
Merge pull request #3033 from plotly/2968-max-dim
fallback to max-width and max-height if necessary
2 parents 7714aa6 + 2ada05d commit 4b52e42

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

src/plots/plots.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -1387,8 +1387,8 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
13871387
// but don't enforce any ratio restrictions
13881388
var computedStyle = isPlotDiv ? window.getComputedStyle(gd) : {};
13891389

1390-
newWidth = parseFloat(computedStyle.width) || fullLayout.width;
1391-
newHeight = parseFloat(computedStyle.height) || fullLayout.height;
1390+
newWidth = parseFloat(computedStyle.width) || parseFloat(computedStyle.maxWidth) || fullLayout.width;
1391+
newHeight = parseFloat(computedStyle.height) || parseFloat(computedStyle.maxHeight) || fullLayout.height;
13921392
}
13931393

13941394
var minWidth = plots.layoutAttributes.width.min,

test/jasmine/tests/config_test.js

+11
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,17 @@ describe('config argument', function() {
163163
testAutosize(autosize, config, layoutHeight, relayoutHeight, done);
164164
});
165165

166+
it('should fill the container when autosize: true up its max-width and max-height', function(done) {
167+
gd.style.maxWidth = '400px';
168+
gd.style.maxHeight = '300px';
169+
Plotly.plot(gd, data, {autosize: true})
170+
.then(function() {
171+
checkLayoutSize(400, 300);
172+
})
173+
.catch(failTest)
174+
.then(done);
175+
});
176+
166177
it('should respect attribute autosizable: false', function(done) {
167178
var autosize = false;
168179
var config = {

0 commit comments

Comments
 (0)