-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdash5.py
More file actions
71 lines (60 loc) · 2.01 KB
/
dash5.py
File metadata and controls
71 lines (60 loc) · 2.01 KB
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import dash
from dash import dcc
from dash import html
from dash.dependencies import Input, Output
import pandas as pd
import plotly.express as px
# Define the app
app = dash.Dash(__name__)
# Load the data from the Excel file
df = pd.read_excel('randomdata_1.xlsx')
# Define the dropdown options
dropdown_options = [
{"label": "Product 1", "value": "Product 1"},
{"label": "Product 2", "value": "Product 2"},
{"label": "Product 3", "value": "Product 3"},
{"label": "Product 4", "value": "Product 4"},
]
# Define the app layout
app.layout = html.Div(
[
# Define the dropdown
dcc.Dropdown(
id="product-dropdown",
options=dropdown_options,
value="Product 1",
),
# Define the graphs
html.Div(
[
dcc.Graph(id="curr-graph"),
dcc.Graph(id="target-graph"),
dcc.Graph(id="lm-graph"),
dcc.Graph(id="ly-graph"),
],
className="row",
),
]
)
# Define the callback to update the graphs
@app.callback(
[
Output("curr-graph", "figure"),
Output("target-graph", "figure"),
Output("lm-graph", "figure"),
Output("ly-graph", "figure"),
],
[Input("product-dropdown", "value")],
)
def update_graphs(product):
# Filter the data for the selected product
filtered_df = df[df["Product"] == product]
# Create the figures for each indicator
curr_fig = px.bar(filtered_df, x="Zones", y="Curr", color="Indicator", barmode="group")
target_fig = px.bar(filtered_df, x="Zones", y="Target", color="Indicator", barmode="group")
lm_fig = px.bar(filtered_df, x="Zones", y="LM", color="Indicator", barmode="group")
ly_fig = px.bar(filtered_df, x="Zones", y="LY", color="Indicator", barmode="group")
# Return the figures
return curr_fig, target_fig, lm_fig, ly_fig
if __name__ == "__main__":
app.run_server(debug=True)