Skip to content
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

[BUG] relayoutData is not reset #905

Closed
orenbenkiki opened this issue Sep 4, 2019 · 3 comments
Closed

[BUG] relayoutData is not reset #905

orenbenkiki opened this issue Sep 4, 2019 · 3 comments

Comments

@orenbenkiki
Copy link

Context

dash (1.1.1)
dash-bootstrap-components (0.7.0)
dash-core-components (1.1.1)
dash-daq (0.1.7)
dash-html-components (1.0.0)
dash-renderer (1.0.0)
dash-table (4.1.0)

Describe the bug

  1. Display a large Heatmap (say, 2000x2000). Resample it so the displayed image is 100x100 by averaging each 20x20 region of the whole data.

  2. Define a callback that takes as input both the relayoutData and also some other input (say, some Dropdown controlling how to process the data for display - for example whether to use the average or minimum or maximum of each region).

  3. Use the mouse to select the bottom left quadrant of the image to zoom into it => The callback will be invoked and the relayoutData will describe the selected region (coordinates 0,0 -> 50,50) => The callback will compute a new 100x100 image by averaging each 10x10 region of the displayed selected 1000x1000 subset of the data.

  4. Again use the mouse to select the bottom left quadrant of the image to zoom into it => The callback will be invoked and the relayoutData will describe the selected region (coordinates 0,0 -> 50,50, same as before) => The callback must apply the selection to the current visible 1000x1000 region => The callback will compute a new 100x100 image by averaging each 5x5 region of the displayed selected 500x500 subset of the data.

BUG:

  1. Change the dropdown to request using the maximal value (instead of the average) of each region => The callback will be invoked and the relayoutData will contain the exact same coordinates 0,0->50,50 even though the user did not select a sub-region to zoom into => The callback must not apply the selection to the currently visible region => The callback must reuse the 500x500 subset of the data to compute the correct 100x100 image to display.

Expected behavior:

In step 5, the relayoutData should cover the whole visible region (coordinates 0,0->100,100), allowing the application to apply it to the currently visible region and get the right image to display.

Workaround

If the callback is invoked twice with exactly the same selection, ignore the selection. This of course assumes that the user doesn't manually select the exact same sub-region of the visible heatmap (such as a specific quadrant) twice in a row.

@alexcjohnson
Copy link
Collaborator

Can you get what you want from dash.callback_context? (see https://dash.plot.ly/faqs "How do I determine which Input has changed?") ie if relayoutData isn't the one that triggered the callback, ignore it.

I see your point, but I'm not sure we can solve it by resetting relayoutData when a new figure is provided - this would generate lots of new relayout events unconnected to actual Plotly.relayout calls generated by the UI, which seems like it would constitute a breaking change. I suspect the better long-term solution is a "live figure" prop plotly/dash-core-components#584

@orenbenkiki
Copy link
Author

orenbenkiki commented Sep 4, 2019

Can you get what you want from dash.callback_context? (see https://dash.plot.ly/faqs "How do I determine which Input has changed?") ie if relayoutData isn't the one that triggered the callback, ignore it.

Good idea, I'll try it tomorrow.

Edit: Just tried it, indeed the relayoutData is not listed in the dash.callback_context unless the user actually did some selection activity, so it is a much better approach than comparing to the data of the previous event. Thanks!

I see your point, but I'm not sure we can solve it by resetting relayoutData when a new figure is provided - this would generate lots of new relayout events unconnected to actual Plotly.relayout calls generated by the UI, which seems like it would constitute a breaking change.

That wasn't what I had in mind; I was hoping for the relatoutData to just be reset to None or contain the full coordinate range or any other indication of "not changed from last time" - not triggering an additional event. The current behavior makes it seem as if the user has again selected a sub-region, which they did not do.

I suspect the better long-term solution is a "live figure" prop plotly/dash-core-components#584

If I understand this correctly, that would be (1) a way to tell Dash that "this data reflects this specific subset of a larger image" and (2) having some property similar to relayoutData but that always works in the coordinates of the larger image, regardless of the current zoom level/pan offset. If so, then yes, this would be a clean and effective solution.

HammadTheOne pushed a commit to HammadTheOne/dash that referenced this issue May 28, 2021
HammadTheOne pushed a commit that referenced this issue Jul 23, 2021
@gvwilson
Copy link
Contributor

Hi - we are tidying up stale issues and PRs in Plotly's public repositories so that we can focus on things that are most important to our community. If this issue is still a concern, please add a comment letting us know what recent version of our software you've checked it with so that I can reopen it and add it to our backlog. (Please note that we will give priority to reports that include a short reproducible example.) If you'd like to submit a PR, we'd be happy to prioritize a review, and if it's a request for tech support, please post in our community forum. Thank you - @gvwilson

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

No branches or pull requests

3 participants