Skip to content

Commit

Permalink
emit 'plotly_afterplot' once during doAutoMargin redraws
Browse files Browse the repository at this point in the history
- N.B. consider this a 'temporary' fix until we improve
  the automargin pipeline, see
  #2704
  for more detail.
  • Loading branch information
etpinard committed Jul 4, 2018
1 parent 22a07a9 commit cb92d7c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 7 additions & 1 deletion src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,13 @@ exports.plot = function(gd, data, layout, config) {
};

function emitAfterPlot(gd) {
gd.emit('plotly_afterplot');
var fullLayout = gd._fullLayout;

if(fullLayout._redrawFromAutoMarginCount) {
fullLayout._redrawFromAutoMarginCount--;
} else {
gd.emit('plotly_afterplot');
}
}

exports.setPlotConfig = function setPlotConfig(obj) {
Expand Down
11 changes: 9 additions & 2 deletions src/plots/plots.js
Original file line number Diff line number Diff line change
Expand Up @@ -1788,8 +1788,15 @@ plots.doAutoMargin = function(gd) {
gs.h = Math.round(fullLayout.height) - gs.t - gs.b;

// if things changed and we're not already redrawing, trigger a redraw
if(!fullLayout._replotting && oldmargins !== '{}' &&
oldmargins !== JSON.stringify(fullLayout._size)) {
if(!fullLayout._replotting &&
oldmargins !== '{}' &&
oldmargins !== JSON.stringify(fullLayout._size)
) {
if('_redrawFromAutoMarginCount' in fullLayout) {
fullLayout._redrawFromAutoMarginCount++;
} else {
fullLayout._redrawFromAutoMarginCount = 1;
}
return Registry.call('plot', gd);
}
};
Expand Down

0 comments on commit cb92d7c

Please sign in to comment.