I have a callback where I use a single pulldown menu selection input to update several graphs on one page using multiple outputs. This works, but takes a long time to run. Is there a way to have these graphs load sequentially? I don’t think it’s possible to tie a single input to multiple callbacks. I thought that would work but it doesn’t. So I need a way to get these graphs to load sequentially instead of all at once. Any ideas? Thanks.
# Callback for events data
@app.callback(
[Output('events-shots', 'figure'), Output('events-assists', 'figure'), Output('events-progressive-passes', 'figure'),
Output('events-crosses', 'figure'), Output('events-set-plays', 'figure'), Output('events-reception-box', 'figure')],
[Input('team-dropdown', 'value')])
def event_graph(team):
if team is not None:
fig_shots = plotEvents('Shots', 'team', team, '127.0.0.1')
fig_assists = plotEvents('Assists to Shots', 'team', team, '127.0.0.1')
fig_crosses = plotEvents('Crosses', 'team', team, '127.0.0.1')
fig_set_plays = plotEvents('Set Plays', 'team', team, '127.0.0.1')
fig_progressive_passes = plotEvents('Progressive Passes Into Final 3rd', 'team', team, '127.0.0.1')
fig_reception_box = plotEvents('Reception in the Box', 'team', team, '127.0.0.1')
for x in [fig_shots, fig_assists,fig_crosses, fig_set_plays, fig_progressive_passes, fig_reception_box]:
# Change modebar drawing item colour so that it stands out (vs. grey)
x.update_layout(newshape=dict(line_color='#009BFF'))
return fig_shots, fig_assists, fig_crosses, fig_set_plays, fig_progressive_passes, fig_reception_box
else:
fig = initial_figure_events()
return fig, fig, fig, fig, fig, fig