Black Lives Matter. Please consider donating to Black Girls Code today.
Dash HoloViews is now available! Check out the docs.

Keep figure and other UI element in previous state, even refreshed or left that particular page

I am new in Plotly dash, Where I am building one application, which has 3 module.

  1. Main Menu (Left Side)
  2. Top Menu (Which creates buttons or tabs, for the URL which we have click from Main Menu)
  3. Div (Which has few figures or charts and also has some drop-down options- when we change value in drop-down and submit, it creates new figures or charts based on updated value)

Point 2, you can consider as a history tabs, all previous clicked tabs buttons.

Suppose we clicked 3 URL from main menu out of 10 URL. Than it will create 3 Buttons and I am using this buttons as a history.
Now I have changed drop-down values and it updated the figure, then I have change tab from Top menu and if I again clicked previous tab from top menu it lost all its previous dropdown and figure changes, It takes all this value default.

So, to store this, I can use cookies or session or some global variable I can use, But I think it is not better idea to store with this, Do we have any better idea in ploty dash

Dash has various ways of keeping state. What you want is not global state but rather session state. The best way to do that is described in the 4th example here. Note that this is vulnerable to session-fixing and other similar attacks, as all such approaches would be. You can use a Redis instance running with the server to keep, record and restore a session-associated state. This is overall preferable to cookies.

Hi Chrisvcsefalvay,

Thanks, Your solution is working for me, I am using the session to store last activity of user, But it looks little bit bulky. I have to use session on each page.
But At last solution is working, If you have some smarter way to complete this task, that would help me.
Thanks Again,…

1 Like