Skip to content

Fire plotly_afterplot after Promise.all callback #1342

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 31, 2017
Merged

Conversation

etpinard
Copy link
Contributor

fixes #1341

@etpinard etpinard added status: reviewable bug something broken labels Jan 30, 2017
@@ -84,6 +84,21 @@ describe('Test plot api', function() {
expect(gd._transitionData._frames[2].name).toEqual('frame3');
}).catch(fail).then(done);
});

it('should emit afterplot event after plotting is done', function(done) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test here fails on master.

I'm not exactly sure why though which might me related to #76

Consider:

var gd = document.getElementById('graph')

Plotly.plot(gd, [{}])

gd.on('plotly_afterplot', () => {})

I suspect that on master the Plotly.plot promise is resolved before gd.on('plotly_relayout, /* */) is set. By tucking gd.emit('plotly_afterplot') is the Promise.all callback the Plotly.plot promise is resolved after gd.on.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suspect that on master the Plotly.plot promise is resolved before gd.on('plotly_afterplot, /* */) is set.

exactly - in most cases the plotting itself is sync, so your fix here is spot on.

@alexcjohnson
Copy link
Collaborator

💃

@etpinard etpinard merged commit 5206b49 into master Jan 31, 2017
@etpinard etpinard deleted the afterplot branch January 31, 2017 15:59
@alexander-daniel
Copy link
Contributor

Just wondering, is this only fired on Plotly.plot calls?

Curious, as I'd love to use this event with the React component, but that seems to use either:
Plotly.newPlot &
Plotly.react

Thanks!

@etpinard
Copy link
Contributor Author

Right, plotly_afterplot should be fired when Plotly.newPlot completes. Not sure why that doesn't happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

Successfully merging this pull request may close these issues.

afterplot event not fired on load
3 participants