Task 5b done

main
Marc Gauch 2023-05-12 15:23:37 +02:00
parent aad677e9be
commit f64cf5ed4d
1 changed files with 7 additions and 6 deletions

View File

@ -53,18 +53,19 @@ app.layout = html.Div(
],
className="m-4",
)
@app.callback(Output("graph_1", "figure"), Input("color", "value"))
@app.callback(Output("graph_1", "figure"), Input("color", "value"), Input("range", "value"))
def update_graph_1(dropdown_value_color):
fig = px.histogram(df, x="y", color_discrete_sequence=[dropdown_value_color])
def update_graph_1(color, range):
dff = df[(df['y'] > range[0]) & (df['y'] < range[1])]
fig = px.histogram(dff, x="y", color_discrete_sequence=[color])
fig.update_layout()
return fig
@app.callback(Output("graph_2", "figure"), Input("range", "value"))
@app.callback(Output("graph_2", "figure"), Input("color", "value"), Input("range", "value"))
def update_graph_2(range):
def update_graph_2(color, range):
dff = df[(df['y'] > range[0]) & (df['y'] < range[1])]
fig = px.scatter(dff, x='x', y='y')
fig = px.scatter(dff, x='x', y='y', color_discrete_sequence=[color])
fig.update_layout()
return fig