Task 5a done
This commit is contained in:
		
							parent
							
								
									9773de31cb
								
							
						
					
					
						commit
						2faaa900a3
					
				@ -13,15 +13,44 @@ app = Dash(__name__, external_stylesheets=[dbc.themes.BOOTSTRAP])
 | 
				
			|||||||
df = pd.DataFrame({'y': np.random.normal(loc=0, scale=10, size=1000),
 | 
					df = pd.DataFrame({'y': np.random.normal(loc=0, scale=10, size=1000),
 | 
				
			||||||
                   'x': np.random.normal(loc=10, scale=2, size=1000)})
 | 
					                   'x': np.random.normal(loc=10, scale=2, size=1000)})
 | 
				
			||||||
 | 
					
 | 
				
			||||||
app.layout = html.Div([html.H1("Dashboard 2"),
 | 
					app.layout = html.Div(
 | 
				
			||||||
    dbc.Row([dbc.Col([dcc.Dropdown(options=['red', 'green', 'blue'], value='red', id='color', multi=False)], width=6),
 | 
					    [
 | 
				
			||||||
             dbc.Col([dcc.Slider(min=math.floor(df['y'].min()), max=math.ceil(df['y'].max()), id="min_value")
 | 
					        html.H1("Dashboard 2"),
 | 
				
			||||||
            ], width=6)
 | 
					        dbc.Row(
 | 
				
			||||||
    ]),
 | 
					            [
 | 
				
			||||||
    dbc.Row([dbc.Col([dcc.Graph(id="graph_1")], width=6),
 | 
					                dbc.Col(
 | 
				
			||||||
             dbc.Col([dcc.Graph(id="graph_2")], width=6)
 | 
					                    [
 | 
				
			||||||
    ])], className="m-4")
 | 
					                        dcc.Dropdown(
 | 
				
			||||||
 | 
					                            options=["red", "green", "blue"],
 | 
				
			||||||
 | 
					                            value="red",
 | 
				
			||||||
 | 
					                            id="color",
 | 
				
			||||||
 | 
					                            multi=False,
 | 
				
			||||||
 | 
					                        )
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                    width=6,
 | 
				
			||||||
 | 
					                ),
 | 
				
			||||||
 | 
					                dbc.Col(
 | 
				
			||||||
 | 
					                    [
 | 
				
			||||||
 | 
					                        dcc.RangeSlider(
 | 
				
			||||||
 | 
					                            min=math.floor(df["y"].min()),
 | 
				
			||||||
 | 
					                            max=math.ceil(df["y"].max()),
 | 
				
			||||||
 | 
					                            value=[math.floor(df["y"].min()), math.ceil(df["y"].max())],
 | 
				
			||||||
 | 
					                            id="range",
 | 
				
			||||||
 | 
					                        )
 | 
				
			||||||
 | 
					                    ],
 | 
				
			||||||
 | 
					                    width=6,
 | 
				
			||||||
 | 
					                ),
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					        dbc.Row(
 | 
				
			||||||
 | 
					            [
 | 
				
			||||||
 | 
					                dbc.Col([dcc.Graph(id="graph_1")], width=6),
 | 
				
			||||||
 | 
					                dbc.Col([dcc.Graph(id="graph_2")], width=6),
 | 
				
			||||||
 | 
					            ]
 | 
				
			||||||
 | 
					        ),
 | 
				
			||||||
 | 
					    ],
 | 
				
			||||||
 | 
					    className="m-4",
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
@app.callback(Output("graph_1", "figure"), Input("color", "value"))
 | 
					@app.callback(Output("graph_1", "figure"), Input("color", "value"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def update_graph_1(dropdown_value_color):
 | 
					def update_graph_1(dropdown_value_color):
 | 
				
			||||||
@ -29,10 +58,10 @@ def update_graph_1(dropdown_value_color):
 | 
				
			|||||||
    fig.update_layout()
 | 
					    fig.update_layout()
 | 
				
			||||||
    return fig
 | 
					    return fig
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@app.callback(Output("graph_2", "figure"), Input("min_value", "value"))
 | 
					@app.callback(Output("graph_2", "figure"), Input("range", "value"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def update_graph_2(min_value):
 | 
					def update_graph_2(range):
 | 
				
			||||||
    dff = df[df['y']> min_value]
 | 
					    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')
 | 
				
			||||||
    fig.update_layout()
 | 
					    fig.update_layout()
 | 
				
			||||||
    return fig
 | 
					    return fig
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user