Dash graph with 2 traces per name

Hi!
I am new to dash.
I have the following callback:

@app.callback(
dash.dependencies.Output(‘graph_3’, ‘figure’),
[dash.dependencies.Input(‘Graphs_no_closing’, ‘value’)])
def update_graph_src(selector):
data = []
for name in selector:
data.append({‘x’: reals_data[name][‘x’], ‘y’: reals_data[name][‘y’], ‘type’: ‘line’, ‘name’: name})
data.append({‘x’: graph_data[name][‘x’], ‘y’: graph_data[name][‘y’], ‘type’: ‘bar’, ‘name’: name})
return fig.figs(‘New_Sales, Churn, Migration_Out’, data, ‘Events’)

I’d like to make reals_data disappear from sidebar checklist, so only one legend per name is visible. Now, I have both line and bar names in the sidebar.

Sidebar legend is in the html.Div:

html.Div([
dcc.Checklist(
id = id,
value=val,
),
],
)

Greetings,
Tom
P.S. is there a way to properly format code?

I made a small step in right direction, I used ‘legendgroup’: name, ‘traceorder’:‘grouped’ in each data.append.
Now, the legend works as I expected, by I still have two identical names per group

Success!!
I wiil read the manual, I promise…

I added ‘showlegend’: False to one and ‘showlegend’: True to second one :innocent:

@app.callback(
dash.dependencies.Output(‘graph_3’, ‘figure’),
[dash.dependencies.Input(‘Graphs_no_closing’, ‘value’)])
def update_graph_src(selector):
data = []
for name in selector:
data.append({‘x’: reals_data[name][‘x’], ‘y’: reals_data[name][‘y’], ‘type’: ‘line’, ‘name’: name, ‘legendgroup’: name, ‘traceorder’:‘grouped’, ‘showlegend’: False})
data.append({‘x’: graph_data[name][‘x’], ‘y’: graph_data[name][‘y’], ‘type’: ‘bar’, ‘name’: name, ‘legendgroup’: name, ‘traceorder’:‘grouped’, ‘showlegend’: True})
return fig.figs(‘New_Sales, Churn, Migration_Out’, data, ‘Events’)