Skip to content

plotly_afterplot Event isn't triggered on pan/zoom #2740

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

Closed
JosephHewitt opened this issue Jun 16, 2018 · 8 comments · Fixed by #2773
Closed

plotly_afterplot Event isn't triggered on pan/zoom #2740

JosephHewitt opened this issue Jun 16, 2018 · 8 comments · Fixed by #2773
Labels
bug something broken regression this used to work

Comments

@JosephHewitt
Copy link

In previous versions of Plotly.js (1.35.2 works) I would use the plotly_afterplot event to detect when a user had panned the graph, but this event is no longer being called when the user pans or zooms.

The issue can be reproduced using your plotly_afterplot example on Codepen. The event only seems to be called when the plot is first drawn and when the axes are reset. I've tested this on the latest version of both Chrome and Safari on MacOS; neither of which have events called from simply panning or zooming the plot.

@alexcjohnson
Copy link
Collaborator

This is likely due to our performance improvements, so axis range changes don’t require a full replot anymore. The plotly_relayout event is really the one you want anyway, as it also tells you what the change was.

@JosephHewitt
Copy link
Author

Thank you, I can confirm plotly_relayout works as expected. I think the documentation for plotly_afterplot needs updating and then this issue is resolved.

@alexcjohnson
Copy link
Collaborator

Good call @JOE95443 - the example at https://plot.ly/javascript/plotlyjs-events/#afterplot-event no longer acts as described.

@etpinard I seem to recall us discussing this before and concluding we no longer even need afterplot, you can just use eg Plotly.newPlot(...).then(...) to accomplish its original purpose (and as this issue shows, the other times it currently fires it really shouldn't be used). So should we update the docs to describe it as deprecated and add this to #420?

@etpinard
Copy link
Contributor

It's true we no longer need plotly_afterplot, but I'm sure some users prefer listening to an event than handling a Promise.resolve in some situations. I'd vote 👎 for removing plotly_afterplot in v2. I don't think afterplot is a great name for such an event, but maybe we could just rename it in v2?

Now, it's true than pan/zoom no longer fires plotly_afterplot, but it isn't the only edit type than doesn't fire it.

So, we have a two options:

  • make the 'axrange' edit type fire plotly_afterplot (fixing this regression) and update that doc page, or
  • make sure all edit types fire plotly_afterplot (like the doc page says)

If you chose to keep an afterplot-like event in v2, than I think we should go with the latter, if not, the former would be best.

@alexcjohnson
Copy link
Collaborator

It's true, if there were one event that always fired after any change to the plot, that could be useful. But what if in v2 this event was plotly_react?

@etpinard
Copy link
Contributor

But what if in v2 this event was plotly_react?

Aren't we planning on renaming Plotly.react -> Plotly.plot in v2?

@alexcjohnson
Copy link
Collaborator

Aren't we planning on renaming Plotly.react -> Plotly.plot in v2?

sure :) Alright, fiddling a little it seems like plotly_afterplot was actually closer to firing after every GUI-initiated change than I thought, so perhaps it is worth extending it to be the one "any change of state" event and then renaming it (amid coalescing with other events) in v2.

@alexcjohnson alexcjohnson added regression this used to work bug something broken labels Jun 18, 2018
@etpinard
Copy link
Contributor

it to be the one "any change of state" event

Sounds great 👌

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

Successfully merging a pull request may close this issue.

3 participants