Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fallback to max-width and max-height if necessary #3033

Merged
merged 2 commits into from
Sep 25, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1387,8 +1387,8 @@ plots.plotAutoSize = function plotAutoSize(gd, layout, fullLayout) {
// but don't enforce any ratio restrictions
var computedStyle = isPlotDiv ? window.getComputedStyle(gd) : {};

newWidth = parseFloat(computedStyle.width) || fullLayout.width;
newHeight = parseFloat(computedStyle.height) || fullLayout.height;
newWidth = parseFloat(computedStyle.width) || parseFloat(computedStyle.maxWidth) || fullLayout.width;
newHeight = parseFloat(computedStyle.height) || parseFloat(computedStyle.maxHeight) || fullLayout.height;
antoinerg marked this conversation as resolved.
Show resolved Hide resolved
}

var minWidth = plots.layoutAttributes.width.min,
Expand Down
11 changes: 11 additions & 0 deletions test/jasmine/tests/config_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,17 @@ describe('config argument', function() {
testAutosize(autosize, config, layoutHeight, relayoutHeight, done);
});

it('should fill the container when autosize: true up its max-width and max-height', function(done) {
gd.style.maxWidth = '400px';
gd.style.maxHeight = '300px';
Plotly.plot(gd, data, {autosize: true})
.then(function() {
checkLayoutSize(400, 300);
})
.catch(failTest)
.then(done);
});

it('should respect attribute autosizable: false', function(done) {
var autosize = false;
var config = {
Expand Down