-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.py
156 lines (145 loc) · 5.16 KB
/
test.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
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
# -*-coding:utf-8 -*-
import dash
import dash_core_components as dcc
import dash_html_components as html
import plotly.express as px
import pandas as pd
# Boostrap CSS and font awesome . Option 1) Run from codepen directly Option 2) Copy css file to assets folder and run locally
external_stylesheets = [
"https://codepen.io/unicorndy/pen/GRJXrvP.css",
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css",
]
app = dash.Dash(__name__, external_stylesheets=external_stylesheets)
app.title = "新北市政府衛生局食安智慧監控中心指標儀表板"
# for heroku to run correctly
server = app.server
# Overwrite your CSS setting by including style locally
colors = {
"background": "#2D2D2D",
"text": "#E1E2E5",
"figure_text": "#ffffff",
"confirmed_text": "#3CA4FF",
"deaths_text": "#f44336",
"recovered_text": "#5A9E6F",
"highest_case_bg": "#393939",
}
# Creating custom style for local use
divBorderStyle = {
"backgroundColor": "#393939",
"borderRadius": "12px",
"lineHeight": 0.9,
}
# Creating custom style for local use
boxBorderStyle = {
"borderColor": "#393939",
"borderStyle": "solid",
"borderRadius": "10px",
"borderWidth": 2,
}
# assume you have a "long-form" data frame
# see https://plotly.com/python/px-arguments/ for more options
df = pd.DataFrame(
{
"Fruit": ["Apples", "Oranges", "Bananas", "Apples", "Oranges", "Bananas"],
"Amount": [4, 1, 2, 2, 4, 5],
"City": ["SF", "SF", "SF", "Montreal", "Montreal", "Montreal"],
}
)
fig = px.bar(df, x="Fruit", y="Amount", color="City", barmode="group")
fig2 = px.line(df, x="Fruit", y="Amount", color="City")
fig.update_layout(
plot_bgcolor=colors["background"],
paper_bgcolor=colors["background"],
font_color=colors["text"],
)
fig2.update_layout(
plot_bgcolor=colors["background"],
paper_bgcolor=colors["background"],
font_color=colors["text"],
)
app.layout = html.Div(
[
html.Div(
[
html.H4("新北政府衛生局", style={"textAlign": "left"}),
html.H6(
"食安智慧監控中心-數據儀表板", style={"textAlign": "left", "color": "#e63946"}
),
],
className="row",
),
html.Div(
[
html.Div(
[
html.H4(
"柱狀範例圖",
style={"textAlign": "center", "color": colors["text"]},
className="row",
),
html.Div(
"Dash: A web application framework for Python.",
style={"textAlign": "center", "color": colors["text"]},
),
dcc.Graph(id="example-graph1", figure=fig),
],
className="six columns",
),
html.Div(
[
html.H4(
"折線圖範例圖",
style={"textAlign": "center", "color": colors["text"]},
className="row",
),
html.Div(
"Dash: A web application framework for Python.",
style={"textAlign": "center", "color": colors["text"]},
),
dcc.Graph(id="example-graph", figure=fig2),
],
className="six columns",
),
],
className="ten columns offset-by-one",
),
html.Div(
[
html.Div(
[
html.H4(
"柱狀範例圖",
style={"textAlign": "center", "color": colors["text"]},
className="row",
),
html.Div(
"Dash: A web application framework for Python.",
style={"textAlign": "center", "color": colors["text"]},
),
dcc.Graph(id="example-graph2", figure=fig),
],
className="six columns",
),
html.Div(
[
html.H4(
"折線圖範例圖",
style={"textAlign": "center", "color": colors["text"]},
className="row",
),
html.Div(
"Dash: A web application framework for Python.",
style={"textAlign": "center", "color": colors["text"]},
),
dcc.Graph(id="example-graph3", figure=fig2),
],
className="six columns",
),
],
className="ten columns offset-by-one",
),
],
className="row",
)
if __name__ == "__main__":
app.run_server(debug=True)