I have a dash app that hosts a model with an interactive interface. As part of development I need to tweak parameters often, and there are a lot of them. The problem is that each time I change an aspect of the model I need to reload the webpage and all of my options reset to default. This is a pain. Is there any way I can save the state of the app and reload this state on refresh? (i.e. with all the options I’ve just configured last time around)?
You can save your state in the URL. Here is an example gist https://github.com/plotly/dash/issues/188#issuecomment-360313359
@cw00137 As of dash==1.3.0
, Dash now supports prop persistence in local storage for many components in dcc and in the table. There’s a usage example in 📣 Dash 1.3.0 released.
Additional tweaking can be on the persistence
props to change the persisted props, the type of persistence and to allow multiple persisted sets of values per component as described in components props reference (e.g. https://dash.plot.ly/datatable/reference)
In dcc,
-
Checklist
,Dropdown
,Input
,RadioItems
,RangeSlider
,Slider,
Tabs,
Textareacan persist
value` -
DatePickerRange
can persiststart_date
andend_date
-
DatePickerSingle
can persistdate
In the table: column_name
, data
(opt-in), selected_columns
, selected_rows
, sort_by
Hope this helps!
Here’s an example of how you can save the state of the app in a querystring: https://github.com/oegedijk/dash_querystrings
This makes the state of the app not only persistent but also shareable. Although if you have a lot of querystring parameters I would suggest implementing a tinyurl shortener in your app. (example also shown in the above github repo)