You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
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.
Store
component. Don't know if it's better to have it inapp.py
or in every page. Thestorage_type
should besession
so that at every new load of the page the figures are cleared. We could use a singleStore
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.Output
the id of theStore
component that we use in the cache, so that every time the plot is also stored in the cache.Input
theurl, 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 theStore
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 itAn 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.
The text was updated successfully, but these errors were encountered: