✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚡️ Concerned about the grid? Kyle Baranko teaches how to predicting peak loads using XGBoost. Register for the August webinar!

Multioutput figures issue

Hello Dash Community!

I’m new to this community, I may be wrong about how to publish. I’m sorry in advance.

I’m trying to multioutput some figures in same callback but when I try to display on multioutput it doesn’t works well. When I do it in two single outputs it works correctly.

Thanks you in advance!!!

Layout:

html.Div([
dbc.Card([
dbc.CardHeader([
html.H4(‘Anomalías caseta’,
className=‘text-style m-0’, id=‘polar-header’),
], className=’’),
dbc.CardBody([
html.Div([
dcc.Graph(
id=“polar-plot”,
figure=dict(
layout=dict(
plot_bgcolor=colors[“graph-bg”],
paper_bgcolor=colors[“graph-bg”],
)
),
style={“height”: “100%”},
)
], className=‘h-100’)
], className=‘h-100’)
], className=‘h-100’)
], className=‘h-50 px-1 pt-2 pb-1’, id=‘polar-plot-container’),
html.Div([
dbc.Card([
dbc.CardHeader([
html.H4(‘Anomalías caseta’,
className=‘text-style m-0’, id=‘polar-header’),
], className=’’),
dbc.CardBody([
html.Div([
dcc.Graph(
id=“bar-polar-plot”,
figure=dict(
layout=dict(
plot_bgcolor=colors[“graph-bg”],
paper_bgcolor=colors[“graph-bg”],
)
),
style={“height”: “100%”},
)
], className=‘h-100’)
], className=‘h-100’)
], className=‘h-100’)
], className=‘h-100 col-6 pl-1 pr-3 py-2’,
id=‘bar-list-graph-container’)

Callback:

@app.callback(
[Output(‘polar-plot’, ‘figure’), Output(‘bar-polar-plot’, ‘figure’),],
[Input(‘url’, ‘pathname’)],)
# [State(‘store-component-clicked’, ‘data’)])
def display_polarplot(x):
“”“Return keysignal4-plot traces and layout”""
if x == ‘/casetas’:
fig, fig2 = hdlr.polar_traces(5, 1)
return [fig, fig2]
else:
return [None, None]

Function:

def polar_traces(array_len, caseta):
“”“Return polar figure”""
listvar = np.random.randint(0, 100, array_len)
rang = np.array(range(array_len + 1))
var = {0:‘corriente inductor’, 1:‘velocidad actual’, 2:‘temperatura’,
3:‘energia’, 4:‘tiro’}
df = pd.DataFrame()
for i in rang:
if i == array_len:
df = df.append(pd.DataFrame([[listvar[0], var[0], caseta]],
columns=[‘value’, ‘var’, ‘caseta’]))
else:
df = df.append(pd.DataFrame([[listvar[i], var[i], caseta]],
columns=[‘value’, ‘var’, ‘caseta’]))

fig = go.Figure(go.Scatterpolar(r=df['value'],
                                theta=df['var'],
                                fill='toself',
                                line_color=colors['signal-line']))
fig.update_layout(dict(
    plot_bgcolor=colors["graph-bg"],
    polar_bgcolor=colors["secondary"],
    paper_bgcolor=colors["graph-bg"],
    font={"color": colors['text'], "size": params['size_font'],
          "family": params['family_font']},
    margin = dict(t=40, b=40, r=40, l=40),
))

fig2 = go.Figure(go.Bar(
        x=df['value'],
        y=df['var'],
        orientation='h'
    ))
return fig, fig2