From 0594ed47b4334ca6e5f7db18385c88ef72b32178 Mon Sep 17 00:00:00 2001 From: archmoj Date: Tue, 20 Oct 2020 14:55:53 -0400 Subject: [PATCH 1/2] discard last margin adjustment when there are too many redraws --- src/plots/plots.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/plots/plots.js b/src/plots/plots.js index ff1e5f9d232..c28b8f3df72 100644 --- a/src/plots/plots.js +++ b/src/plots/plots.js @@ -2032,6 +2032,7 @@ plots.doAutoMargin = function(gd) { if(fullLayout._redrawFromAutoMarginCount < maxNumberOfRedraws) { return Registry.call('plot', gd); } else { + fullLayout._size = oldMargins; Lib.warn('Too many auto-margin redraws.'); } } From e01d09ab0c22c0d4c30b0a3146079bda3c0e1a58 Mon Sep 17 00:00:00 2001 From: archmoj Date: Tue, 20 Oct 2020 15:19:31 -0400 Subject: [PATCH 2/2] add jasmine test to lock issue 5213 - adjust pie test --- test/jasmine/tests/pie_test.js | 2 +- test/jasmine/tests/toimage_test.js | 32 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/test/jasmine/tests/pie_test.js b/test/jasmine/tests/pie_test.js index 328240666f6..c22f9d4decf 100644 --- a/test/jasmine/tests/pie_test.js +++ b/test/jasmine/tests/pie_test.js @@ -1007,7 +1007,7 @@ describe('Pie traces', function() { textposition: [['outside', 'outside', 'inside', 'inside', 'outside']], 'outsidetextfont.size': 12 }, { - t: '~=', l: 'shrunk', + t: '~=', l: '~=', b: 'grew', r: 'grew' })) .then(check('automargin:false', {automargin: false}, { diff --git a/test/jasmine/tests/toimage_test.js b/test/jasmine/tests/toimage_test.js index e4090d1bff9..0f8d649dddc 100644 --- a/test/jasmine/tests/toimage_test.js +++ b/test/jasmine/tests/toimage_test.js @@ -318,5 +318,37 @@ describe('Plotly.toImage', function() { .catch(failTest) .then(done); }); + + it('record and export computed margins with "Too many auto-margin redraws"', function(done) { + Plotly.toImage({ + data: [{ + x: [ + 'a', + 'b', + 'looooooooooooooooooooooooooooooooooog', + 'd' + ] + }], + layout: { + width: 400, + height: 400, + paper_bgcolor: 'lightblue', + xaxis: { + automargin: true + }, + yaxis: { + automargin: true + } + } + }, imgOpts) + .then(function(fig) { + fig = JSON.parse(fig); + var computed = fig.layout.computed; + expect(computed.margin.b).toBeGreaterThan(80); + expect(computed.margin.r).toBeGreaterThan(80); + }) + .catch(failTest) + .then(done); + }); }); });