-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Adding traces on hover can cause infinite loops #1467
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
Comments
I think either 1.24.1 or 1.24.2 might already fix this. See: #1446 |
Thanks for posting @cpsievert ! #1446 fixed a We should fix this before releasing |
Ok. This problem is pretty tricky and is quite frankly (unless @cpsievert can prove otherwise) an edge case. The infinite loop is triggered only when In @cpsievert 's http://codepen.io/cpsievert/pen/dvWydK, an infinite loop is triggered since #1304 because:
Now, how to fix this problem? In my opinion, I think the most robust solution would be to make @rreusser @alexcjohnson event data updates wasn't 🔒 ed down in the #1304 tests, so I guess this would be ok? |
Honestly I'm not sure if I would consider this a bug - yes it's an infinite loop, but you'd get an explosion of traces in a case like this anyway, at least for real data sets where you cause hundreds of hover events every time the mouse crosses the plot. And I do think we want rehover-hovers to emit an event so the more typical case of updating something outside the plot (or on a different subplot at least) will still happen. Is there a more realistic use case for this? There are always going to be ways to trigger infinite loops when you modify a plot from inside an event handler, and I think at some level it's up to the user to avoid these, otherwise we'll be restricting what they can do. |
I'm using it to implement all of this -- https://cpsievert.github.io/plotly_book/linking-views-without-shiny.html
I do a check to make sure I don't add the same trace twice. The example I linked to was a simplified version to help isolate the issue. |
@cpsievert just to clarify: the objective of #1304 is to update the hover state when the plot changes, e.g. streaming or animation and maybe a few other cases @alexcjohnson mentioned that were considered long-running issues where the hover state reflected outdated data until new mouse input triggered a new hover. I think |
After that check do you still have a problem (and if so can you post it?), or were you just hoping not to need the check? I wouldn't want to add a new event type for rehover, because then people would have to know that in the normal case they need to listen to both types. But we could certainly add something to the event to indicate whether it was triggered by a mouse event or something else like a rehover. Like... the mouse event itself? That could come in handy for other purposes too. |
Ooops -- I thought I had implemented that check, but it appears I haven't yet. Will work on it and report back if I still have issues, thanks! |
Looks like this issue is up in the air. Dropping from |
This seems to have broken the last codepen on the hover event docs page https://plot.ly/javascript/hover-events/ https://codepen.io/plotly/pen/eJOyej FYI @cldougl |
This issue has been tagged with A community PR for this feature would certainly be welcome, but our experience is deeper features like this are difficult to complete without the Plotly maintainers leading the effort. Sponsorship range: $5k-$10k What Sponsorship includes:
Please include the link to this issue when contacting us to discuss. |
Hi - this issue has been sitting for a while, so as part of our effort to tidy up our public repositories I'm going to close it. If it's still a concern, we'd be grateful if you could open a new issue (with a short reproducible example if appropriate) so that we can add it to our stack. Cheers - @gvwilson |
MRE of the problem (hover on any of the markers) -- http://codepen.io/cpsievert/pen/dvWydK
FYI this was working pre-1.24.0 -- http://codepen.io/cpsievert/pen/qrmBVx
The text was updated successfully, but these errors were encountered: