I’m trying to use check boxes to disable auto updating. The idea is that if the box is checked then the output will update, if it’s not checked then it will not update. The problem is that if I check and uncheck a box then updating stops entirely. I want to always update if the dcc.checklist is checked and never update if it is not for each output…
Here is my code:
app.layout = html.Div([
dcc.Interval(
id='interval-component',
interval=10*1000, # in milliseconds
n_intervals=0
),
html.H1('Title'),
html.H2('Iframe Title'),
html.Div([
dcc.Checklist(
id='checklist',
options=[
{'label': 'Auto Update Map', 'value': 'Yes'},
],
values=['Yes']
),
],style=dict(display='inline-block',verticalAlign='top',width='30%')),
html.Div([
html.Iframe(id = 'iframe', height = 500, width = 1200)
]),
html.H2('Graph Title'),
html.Div([
dcc.Checklist(
id='checklist-2',
options=[
{'label': 'Auto Update Graph', 'value': 'Yes'},
],
values=['Yes']
),
],style=dict(display='inline-block',verticalAlign='top',width='30%')),
html.Div([
dcc.Graph(id='graph')
]),
])
@app.callback(
Output('graph','figure'),
[Input('interval-component', 'n_intervals')],
[State('checklist-2', 'values')])
def update_graph(n_intervals,checklist2_values):
if checklist2_values:
#create plotly figure
return fig
@app.callback(
Output('iframe','srcDoc'),
[Input('interval-component', 'n_intervals')],
[State('checklist', 'values')]
)
def update_iframe(n_intervals,checklist_values):
if checklist_values:
#create html
return open(path+'myhtml.html','r').read()