From f64cf5ed4dccb965eb0462cdbfdabd366ad26490 Mon Sep 17 00:00:00 2001 From: Marc Gauch <34353267+marcgauch@users.noreply.github.com> Date: Fri, 12 May 2023 15:23:37 +0200 Subject: [PATCH] Task 5b done --- dashboard2/main.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/dashboard2/main.py b/dashboard2/main.py index 1e003b8..fbde1d5 100644 --- a/dashboard2/main.py +++ b/dashboard2/main.py @@ -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