2
votes

My Dash App is currently of two pages besides the index page, and it consists of the following files.

App.py
index.py
app1.py
app2.py

I have a slider on page 1 of the app, namely in app1.py. The slider value is the input of a callback to make a plot on page 1 of the app.

If I would like to use the same slider value for another callback in page 2 of the app to plot something else. How do I pass the slider value into app2.py?

1
Please note that the slider is only on page 1. There is no slider on page 2. Thanks! - BonnieBing

1 Answers

2
votes

You can store its value in a dcc.Store (https://dash.plot.ly/dash-core-components/store ) component (in app1):

@app.callback(
Output('dcc_store_compoenent_id', 'data')
[Inputs('your_slider_id', 'value')]
def store_slider_value_in_dcc_store(slider_value):
    return {'slider_app1_value': slider_value}

Then you can trig your callback (in app2) with whatever you want and access the data with a State on your dcc.State component:

@app.callback(
Output('the_output', 'you_want')
[Inputs('whatever', 'you_want')]
[State('dcc_store_compoenent_id', 'data'])
def func(input_value, data):
    slider_value = data['slider_app1_value']
    ...