diff --git a/src/plots/plots.js b/src/plots/plots.js index 4cc227fb3cb..8f172d14ba0 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -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; } var minWidth = plots.layoutAttributes.width.min, diff --git a/test/jasmine/tests/config_test.js b/test/jasmine/tests/config_test.js index 3b360d93dc5..b20814ceaa8 100644 --- a/test/jasmine/tests/config_test.js +++ b/test/jasmine/tests/config_test.js @@ -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 = {