-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmy_dash_app.py
More file actions
26 lines (26 loc) · 840 Bytes
/
my_dash_app.py
File metadata and controls
26 lines (26 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from dash import Dash, dcc, html, Input, Output
import plotly.express as px
import pandas as pd
app = Dash(__name__)
df = px.data.gapminder()
app.layout = html.Div([
html.H1("Gapminder Data Dashboard"),
dcc.Dropdown(
id='continent-dropdown',
options=[{'label': c, 'value': c} for c in df['continent'].unique()],
value='Asia'
),
dcc.Graph(id='scatter-plot')
])
@app.callback(
Output('scatter-plot', 'figure'),
Input('continent-dropdown', 'value')
)
def update_chart(selected_continent):
filtered_df = df[df['continent'] == selected_continent]
fig = px.scatter(filtered_df, x='gdpPercap', y='lifeExp',
size='pop', color='country', hover_name='country',
log_x=True, size_max=60)
return fig
if __name__ == '__main__':
app.run(debug=True)