Skip to content

Commit 588cc04

Browse files
authored
Merge pull request #5225 from plotly/fix5213-rec-margins-with-too-many-redraws
Record last actual margins when plot involving too many redraws
2 parents 2504f1e + e01d09a commit 588cc04

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

src/plots/plots.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2032,6 +2032,7 @@ plots.doAutoMargin = function(gd) {
20322032
if(fullLayout._redrawFromAutoMarginCount < maxNumberOfRedraws) {
20332033
return Registry.call('plot', gd);
20342034
} else {
2035+
fullLayout._size = oldMargins;
20352036
Lib.warn('Too many auto-margin redraws.');
20362037
}
20372038
}

test/jasmine/tests/pie_test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1007,7 +1007,7 @@ describe('Pie traces', function() {
10071007
textposition: [['outside', 'outside', 'inside', 'inside', 'outside']],
10081008
'outsidetextfont.size': 12
10091009
}, {
1010-
t: '~=', l: 'shrunk',
1010+
t: '~=', l: '~=',
10111011
b: 'grew', r: 'grew'
10121012
}))
10131013
.then(check('automargin:false', {automargin: false}, {

test/jasmine/tests/toimage_test.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,5 +318,37 @@ describe('Plotly.toImage', function() {
318318
.catch(failTest)
319319
.then(done);
320320
});
321+
322+
it('record and export computed margins with "Too many auto-margin redraws"', function(done) {
323+
Plotly.toImage({
324+
data: [{
325+
x: [
326+
'a',
327+
'b',
328+
'looooooooooooooooooooooooooooooooooog',
329+
'd'
330+
]
331+
}],
332+
layout: {
333+
width: 400,
334+
height: 400,
335+
paper_bgcolor: 'lightblue',
336+
xaxis: {
337+
automargin: true
338+
},
339+
yaxis: {
340+
automargin: true
341+
}
342+
}
343+
}, imgOpts)
344+
.then(function(fig) {
345+
fig = JSON.parse(fig);
346+
var computed = fig.layout.computed;
347+
expect(computed.margin.b).toBeGreaterThan(80);
348+
expect(computed.margin.r).toBeGreaterThan(80);
349+
})
350+
.catch(failTest)
351+
.then(done);
352+
});
321353
});
322354
});

0 commit comments

Comments
 (0)