Hi,
I’m using a callback to return a DIV to dash tab and it generates the following error:
dash._grouping.SchemaTypeValidationError: Schema: [<Output `tabs_mpm_content.children`>, <Output `tabs_mpm.value`>]
Path: ()
Expected type: (<class 'tuple'>, <class 'list'>)
Received value of type <class 'dash.html.Div.Div'>:
Div(Graph(id='graph-with-slider'))
My code is:
app.layout = html.Div([
[..........]
dcc.Tabs(id="tabs_mpm", value='graph-with-slider', style={'width': '80%'}, children=[
dcc.Tab(label='Casos Novos', value='graph-with-slider'),
dcc.Tab(label='Baixados', value='graph-baixas'),
dcc.Tab(label='Pendentes', value='graph-pendentes'),
dcc.Tab(label='TC', value='graph-tc'),
dcc.Tab(label='IAD', value='graph-iad'),
dcc.Tab(label='Sentenças', value='graph-sent'),
dcc.Tab(label='Decisões', value='graph-dec'),
dcc.Tab(label='Audiências', value='graph-aud')
]),
html.Div(id='tabs_mpm_content', children=[
dcc.Graph(id='graph-selecionado')],
style={'width': '80%', 'display': 'inline-block', 'vertical-align': 'middle'}
)
Show graph based on tab selection function:
@app.callback(Output('tabs_mpm_content', 'children'),
Output('tabs_mpm', 'value'),
Input('tabs_mpm', 'value'))
def render_content(tab):
if tab == 'graph-with-slider':
return html.Div(
dcc.Graph(id='graph-with-slider')
)
elif tab == 'graph-baixas':
return html.Div(
dcc.Graph(id='graph-baixas')
)
elif tab == 'graph-pendentes':
return html.Div(
dcc.Graph(id='graph-pendentes')
)
elif tab == 'graph-tc':
return html.Div(
dcc.Graph(id='graph-tc')
)
elif tab == 'graph-iad':
return html.Div(
dcc.Graph(id='graph-iad')
)
elif tab == 'graph-sent':
return html.Div(
dcc.Graph(id='graph-sent')
)
elif tab == 'graph-dec':
return html.Div(
dcc.Graph(id='graph-dec')
)
elif tab == 'graph-aud':
return html.Div(
dcc.Graph(id='graph-aud')
)
I know the error message is about returning DIV instead of a list, but how should I fix it?