I made a callback function which depends on multiple dropdown menus and range sliders as input to produce one heatmap. Similar to this:
@app.callback(
dash.dependencies.Output(‘heat’, ‘figure’),
[dash.dependencies.Input(‘intermediate-value’, ‘data’),
dash.dependencies.Input(‘dropdown’, ‘value’),
dash.dependencies.Input(‘colour’, ‘value’),
dash.dependencies.Input(‘slider’, ‘value’),
dash.dependencies.Input(‘dropdown2’, ‘value’)])
def update_figure(value, dropdown, colour, slider, dropdown2):
do lots of computations based on all input except for colour
fig = go.Figure()
if colour is None:
fig.add_trace(go.Heatmap())
else:
fig.add_trace(go.Heatmap(colorscale=colour))
return fig
But the computing takes a lot of time. Is there a possibility that if the color option is chosen later on, to skip all the computation and only add the color scale to the heatmap? Because now every time I select another colour option, the entire computation is repeated which takes too long time.
How to make another new callback with only selected colour as the input value and the new figure as output which is the figure created in another callback function based on multiple other inputs?