My question is almost something like this, i.e, using update on click, but the difference is that I need to allow update on initial callback.
I have some datatable that are editable. I don’t want to activate callback each time user edit a cell in data table. So I put a button at the end. I have also some figures that I want to show them at the opening, so initial callback is required.
The following code comes from the question mentioned.
@app.callback(
Output("updated-graph", "figure"),
[Input("update-button", "n_clicks")],
[State("update-dropdown", "value")],
)
def update_figure(n_clicks, value):
if n_clicks is None:
return dash.no_update
return {
"data": [go.Scatter(x=[1, 2, 3], y=[int(value)] * 3)],
"layout": go.Layout(
title="number of clicks: " + str(n_clicks),
yaxis={"title": "Selected value"},
),
}