Update multiple graphs from multiple threads in dash, python


I am unable to find a good solution on how to implement updating multiple graphs from threads in my dash app in python.

Goal of the applicaiton

  1. Have a drop down to select stocks ( Ex: aapl, tsla…)
  2. After a button click , create different independent graphs for each stock ( different graphs with ids: graph-aapl, graph-tsla,…)
  3. Create threads for each stock selected and the threads will perform some technical analysis and at the end update its graph ( graph-aapl, graph-tsla ) with data

Progress so far.
I am able to create the drop downs and have a call back to create dynamic graphs.

app.layout = html.Div(
html.Div(className=‘row’, # Define the row element
# Define the left element
html.Div(className=‘three columns div-user-controls’,
dcc.Dropdown(id=‘stockselector’, options=coins,
multi=True, value=[‘aapl’],
‘backgroundColor’: ‘#1E1E1E’},
style={‘color’: ‘#1E1E1E’}),
html.Button(‘Scan Coins’, id=‘button’)

                 # Define the right element
                  html.Div(id="graphs", className='nine columns div-for-charts bg-grey',

Callback for timeseries price

@app.callback(Output(‘graphs’, ‘children’),
[Input(‘scan-submit’, ‘n_clicks’)],
[State(‘graphs’, ‘children’),
State(‘stockselector’, ‘value’)])
def update_graphs(n_clicks, old_output, input1, input2, input3):

if(n_clicks == 0):

# Construct the graph Modules on the page
graph_modules = []
for coin in input1:
    graph_modules.append(html.Div(dcc.Graph(id='graph-' + coin, config={
        'displayModeBar': False}, animate=True)))

# Start the Analysis Thread
th = threading.Thread(target=start_analysis, args=(input1, input3))

return graph_modules

i can see that i have mulitple graphs now on my APP.

How can i update these graphs from different threads? i have seen the calback approach but the data frame is in the thread and how can i pass a figure from thread to the call back ?

Also since my graphs are dynamic , how can i have callbacks for dynamic content before creating them?

Any help is appreciated.

Thank you ,

i was able to do it in dynamic call backs but not exactly as i wanted. i had to create a button that can give more divs when clicked and handle them individually. I am just starting to learn dash. probably soon i ll figure out