Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -36,9 +36,14 @@ def fetch_data(hospital_url, table_id, hospital_name):
|
|
36 |
|
37 |
return pd.DataFrame(data, columns=columns)
|
38 |
|
39 |
-
#
|
40 |
-
def
|
41 |
-
fig = px.
|
|
|
|
|
|
|
|
|
|
|
42 |
st.plotly_chart(fig)
|
43 |
|
44 |
# Streamlit UI
|
@@ -97,7 +102,8 @@ if st.button("爬取資料"):
|
|
97 |
|
98 |
# 添加繪製按鈕
|
99 |
if st.button("繪製圖表"):
|
100 |
-
|
|
|
101 |
|
102 |
else:
|
103 |
st.error("沒有成功爬取任何數據。")
|
|
|
36 |
|
37 |
return pd.DataFrame(data, columns=columns)
|
38 |
|
39 |
+
# 定義繪製圓餅圖的函數
|
40 |
+
def plot_pie_chart(df):
|
41 |
+
fig = px.pie(df, names='病床種類', values='床位別數', title='各類病床床位佔比')
|
42 |
+
st.plotly_chart(fig)
|
43 |
+
|
44 |
+
# 定義繪製柱狀圖的函數
|
45 |
+
def plot_bar_chart(df):
|
46 |
+
fig = px.bar(df, x='病床種類', y='床位別數', color='醫院', barmode='group', title="各醫院病床分佈")
|
47 |
st.plotly_chart(fig)
|
48 |
|
49 |
# Streamlit UI
|
|
|
102 |
|
103 |
# 添加繪製按鈕
|
104 |
if st.button("繪製圖表"):
|
105 |
+
plot_pie_chart(all_data)
|
106 |
+
plot_bar_chart(all_data)
|
107 |
|
108 |
else:
|
109 |
st.error("沒有成功爬取任何數據。")
|