Black Lives Matter. Please consider donating to Black Girls Code today.

Update dcc.Graphs by selecting trace from other chart

Hi, i have a dashboard which cointains multiple graphs. All graphs are created outside of the app.Layout. like this.
I have several more graphs.

All graphs contain the Date Value, so each date is a trace in this graph on xaxis i have the time in hours and on y different values. I want to select a date (trace) from e.g. fig5line (id="g5) and fig6line (id="g6) should update so that i have only the selected trace in g6.

I found some examples, but i cant use a forloop and sometimes later there might be 3 or 5 or 7 traces so i think i have to create the figures outside of app.layout. Please help if anyone has an idea. Thank you very much

#5. chart, line and markers
fig5line = px.scatter(dfresult, x="Time", 
                      y="Total Feed In", 
                      color="Date",
                      title = "Energy ",

                      template=dark)

name = []
name = dfresult.Date.unique().tolist()
fig5line.update_layout(hovermode='closest')

for i in range(len(fig5line.data)):
    fig5line.data[i].update(mode='markers+lines',name=str(name[i]))
    
    
#6. chart, line and markers
fig6line = px.scatter(dfresult, x="Time", 
                      y="Wind Speed", 
                      color="Date",
                      title = "",
                      template=dark,
                      
                      )

app.layout = html.Div([
                           dcc.Graph(id="g5",style={"width":graphwidth,
                                             "height": graphheight,
                                                   
                                                   'display': 'inline-block', 
                                                   
                                                   
                                                   }, 
                              figure=fig5line,
                              ),
                    dcc.Graph(id="g6",style={"width":graphwidth,
                                                  "height": graphheight,
                                                   'display': 'inline-block', 
                                                   
                                                   
                                                   }, 
                              figure=fig6line, 
                             ),