Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -122,34 +122,9 @@ if st.button("點擊開始爬取資料並生成圖表"):
|
|
122 |
margin=dict(l=50, r=50, t=80, b=50)
|
123 |
)
|
124 |
|
125 |
-
# 創建 Sunburst 圖,使用 'Count' 作為數值欄位,而非 'Title'
|
126 |
-
fig_sunburst = px.sunburst(
|
127 |
-
df,
|
128 |
-
path=['District', 'Title'], # District 作為第一層,Title 作為第二層
|
129 |
-
values='Count', # 使用 Count 來作為數值
|
130 |
-
title='餐廳分佈 Sunburst 圖'
|
131 |
-
)
|
132 |
-
|
133 |
-
fig_sunburst.update_layout(
|
134 |
-
title={
|
135 |
-
'text': "餐廳分佈 Sunburst 圖",
|
136 |
-
'y':0.95,
|
137 |
-
'x':0.5,
|
138 |
-
'xanchor': 'center',
|
139 |
-
'yanchor': 'top',
|
140 |
-
'font': dict(size=24, family="Arial", color="DarkSlateGray")
|
141 |
-
},
|
142 |
-
plot_bgcolor='rgba(240,240,240,0.8)',
|
143 |
-
paper_bgcolor='white',
|
144 |
-
font=dict(family="Arial", size=14),
|
145 |
-
hoverlabel=dict(bgcolor="white", font_size=14),
|
146 |
-
margin=dict(l=50, r=50, t=80, b=50)
|
147 |
-
)
|
148 |
-
|
149 |
# 在 Streamlit 中顯示圖表
|
150 |
st.plotly_chart(fig_bar, use_container_width=True)
|
151 |
st.plotly_chart(fig_pie, use_container_width=True)
|
152 |
-
st.plotly_chart(fig_sunburst, use_container_width=True)
|
153 |
|
154 |
# 顯示統計結果
|
155 |
st.write("各區餐廳數量統計表")
|
@@ -157,4 +132,4 @@ if st.button("點擊開始爬取資料並生成圖表"):
|
|
157 |
|
158 |
# 顯示原始數據框
|
159 |
st.write("原始餐廳資料")
|
160 |
-
st.dataframe(df)
|
|
|
122 |
margin=dict(l=50, r=50, t=80, b=50)
|
123 |
)
|
124 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
# 在 Streamlit 中顯示圖表
|
126 |
st.plotly_chart(fig_bar, use_container_width=True)
|
127 |
st.plotly_chart(fig_pie, use_container_width=True)
|
|
|
128 |
|
129 |
# 顯示統計結果
|
130 |
st.write("各區餐廳數量統計表")
|
|
|
132 |
|
133 |
# 顯示原始數據框
|
134 |
st.write("原始餐廳資料")
|
135 |
+
st.dataframe(df)
|