Skip to content

Framework - preserve plot state #1002

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

Anders2303
Copy link
Collaborator

Creates a wrapper around plotly-react that should make ui state more stable. All this is doing is creating stable copies of provided data and layout objects, and injecting the uirevision prop to a fixed string if none is given (implementers can still trigger ui-resets by setting the prop manually, if needed).

Generally, this makes plots more stable, and partially solves #223, but there are still cases where where the ui ends up resetting, and it's hard to pinpoint exactly what causes it. Some causes seem to be:

  • Many re-renders
  • Data and layout changing during fetching, (populated -> empty -> populated)
    • I added a plotUpdateReady prop to stop the component from updating internally while fetching
  • Some components are unmounting the component to show a loading icon, which (naturally) resets the state.
  • Sometimes, it seemingly resets for no reason...

Generally, all plot components should be refactored to: keep the plotly comp mounted, memoize data/layout, use the new prop to avoid uneccessary internal state updates

Future work

As mentioned, the uirevision approach is still very unstable. I think this band-aid solution is better than nothing, but we should probably consider a proper react-like ui state wrapper in the future, where we manually track ui changes and store them in the state, reapplying them each render (PR #231 presents a spike for this)

@Anders2303 Anders2303 requested a review from rubenthoms May 23, 2025 10:51
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

Successfully merging this pull request may close these issues.

1 participant