Skip to content

Commit cb92d7c

Browse files
committedJul 4, 2018
emit 'plotly_afterplot' once during doAutoMargin redraws
- N.B. consider this a 'temporary' fix until we improve the automargin pipeline, see #2704 for more detail.
1 parent 22a07a9 commit cb92d7c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed
 

‎src/plot_api/plot_api.js

+7-1
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,13 @@ exports.plot = function(gd, data, layout, config) {
380380
};
381381

382382
function emitAfterPlot(gd) {
383-
gd.emit('plotly_afterplot');
383+
var fullLayout = gd._fullLayout;
384+
385+
if(fullLayout._redrawFromAutoMarginCount) {
386+
fullLayout._redrawFromAutoMarginCount--;
387+
} else {
388+
gd.emit('plotly_afterplot');
389+
}
384390
}
385391

386392
exports.setPlotConfig = function setPlotConfig(obj) {

‎src/plots/plots.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -1788,8 +1788,15 @@ plots.doAutoMargin = function(gd) {
17881788
gs.h = Math.round(fullLayout.height) - gs.t - gs.b;
17891789

17901790
// if things changed and we're not already redrawing, trigger a redraw
1791-
if(!fullLayout._replotting && oldmargins !== '{}' &&
1792-
oldmargins !== JSON.stringify(fullLayout._size)) {
1791+
if(!fullLayout._replotting &&
1792+
oldmargins !== '{}' &&
1793+
oldmargins !== JSON.stringify(fullLayout._size)
1794+
) {
1795+
if('_redrawFromAutoMarginCount' in fullLayout) {
1796+
fullLayout._redrawFromAutoMarginCount++;
1797+
} else {
1798+
fullLayout._redrawFromAutoMarginCount = 1;
1799+
}
17931800
return Registry.call('plot', gd);
17941801
}
17951802
};

0 commit comments

Comments
 (0)
Please sign in to comment.