Hello,
I am new to dash/plotly/python. Worked quite diligently incorporate a much needed improvement in a graphing tool I am using however I wanted to stop the callback updates. I have tried the below code with success starting the callback, but it won’t stop it. Can someone please help me?
app.layout = html.Div(
html.Div([
html.Button(id='button', children='Enable dcc.Interval'),
dcc.Graph(id='live-update-graph'),
dcc.Interval(
id='interval-component',
interval=1*1000, # in milliseconds
n_intervals=0,
max_intervals=0,
),
])
)
## Callback to turn on interval, to trigger second callback.
@app.callback(
Output(component_id='interval-component', component_property='max_intervals'),
[Input(component_id='button', component_property='n_clicks_timestamp')]
)
def enable_interval_update(button):
if not button:
button = 0
if button > 0:
return -1 ## If button clicked, enabling interval component so it starts running.
else:
return 0
@app.callback(Output('live-update-graph', 'figure'),
[Input('interval-component', 'n_intervals')])
def update_graph_live(n):
some graphing function
return fig