Can I update the state on one page of a chart using an action on another page?

I have a multipage dash chart, though the code is all stored in a single file. I want to use the second page of the chart as a list of configuration options (for example, pick a date range) and then I want to update the graphs on the first page based on the user selections. My first idea is to store the configuration settings in a local file and then read from the local file. I was curious if it might be possible to store that information in a dcc.store state instead even though the dashboard has two pages.

Hello @ibenok,

Yes, you can store information across multiple pages in a dcc.Store. Just put the dcc.Store in the app’s overall layout and go from there. :slight_smile:

1 Like

I tried to store things in dcc store and I got an error that says the dcc store object is an invalid object. What does that mean? I don’t understand what the reason might be that a dcc store object is invalid.

dcc.Stores and all other items going to the client have to be json encoded.

This includes variables that you receive from inputs, etc.

My recommendation would be to convert your user inputs into a dictionary that you then pass to the dcc.Store. As a dictionary has keywords to help pull the information back quicker.

Oh, so I can’t pass “1” to a dcc store object, I have to pass pd.to_json(pd.DataFrame(dict(col = [1, 2, 3]))) instead.

Is that right?

No, you should be able to pass a 1 to a dcc.Store.

Is a dcc.Store added to the layout in order to be used?

Yep I added it to the layout but I got an invalid component error. It’s just like this: dcc.store(id = ‘thisisaDccStoreObject’)

Pass it empty data, like this data=[]