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

Implement persistence for Graph objects #88

Open
3 tasks
guidocioni opened this issue Jan 29, 2024 · 1 comment
Open
3 tasks

Implement persistence for Graph objects #88

guidocioni opened this issue Jan 29, 2024 · 1 comment
Assignees

Comments

@guidocioni
Copy link
Owner

guidocioni commented Jan 29, 2024

  • Add a Store component. Don't know if it's better to have it in app.py or in every page. The storage_type should be session so that at every new load of the page the figures are cleared. We could use a single Store component and save the figure there in a dict with a key being the name of the figure. We have to check if this works with pattern matching callback.
  • In the callback that we already have in every page that creates a figure, add as Output the id of the Store component that we use in the cache, so that every time the plot is also stored in the cache.
  • In the same callback (I think) we can add as Input the url, pathname. Then we check first of all if we're on the right page (using the pathname). If yes, we then check if the figure is already in the Store component. If yes we return it immediately (the cache is only from the session so this is fine). If no, we proceed in generating the image (as usual) and we return it

An example is here
https://stackoverflow.com/questions/63611740/how-to-persist-state-of-plotly-graph-in-dash-app

Also consider this
https://www.dash-extensions.com/sections/pages
If we use this pages extension then the content is not loaded every time from scratch.

@guidocioni guidocioni self-assigned this Jan 29, 2024
@guidocioni guidocioni changed the title Use store for plots? Cache plots for the session Jun 21, 2024
@guidocioni guidocioni changed the title Cache plots for the session Implement persistence for Graph objects Jun 21, 2024
@guidocioni
Copy link
Owner Author

I think if we use the second approach (with dash-extensions pages) everything will be persisted and we won't have to write any function to manually cache the values.
This could also be not bad.

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

1 participant