-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdash_layout.py
37 lines (30 loc) · 1.09 KB
/
dash_layout.py
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
27
28
29
30
31
32
33
34
35
36
37
# Import required packages
import pandas as pd
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
from dash.dependencies import Input, Output
# Add Dataframe
df = pd.DataFrame({
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
"Amount": [4, 1, 2, 2, 4, 5],
"City": ["SF", "SF", "SF", "NYC", "MTL", "NYC"]
})
# Add a bar graph figure
fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")
app = dash.Dash()
app.layout = html.Div(children=[#Title
html.H1(children='Dashboard', style={'textAlign': 'center'}),
# Create dropdown
dcc.Dropdown(options=[
{'label': 'New York City', 'value': 'NYC'},
{'label': 'Montréal', 'value': 'MTL'},
{'label': 'San Francisco', 'value': 'SF'}],
value='NYC'),# Providing a vallue to dropdown
# Bar graph
dcc.Graph(id='example-graph-2',figure=fig)
])
# Run Application
if __name__ == '__main__':
app.run_server()