Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -71,25 +71,29 @@ if st.sidebar.button("載入資料"):
|
|
71 |
x_column = st.selectbox("選擇 X 軸欄位", options=df.columns)
|
72 |
y_column = st.selectbox("選擇 Y 軸欄位", options=numeric_columns)
|
73 |
|
74 |
-
#
|
75 |
-
st.subheader("資料視覺化")
|
76 |
chart_type = st.radio("選擇圖表類型", ("圓餅圖", "柱狀圖"))
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
|
|
|
93 |
else:
|
94 |
st.warning("沒有足夠的數值型欄位來創建圖表。請選擇另一個數據集。")
|
95 |
|
|
|
71 |
x_column = st.selectbox("選擇 X 軸欄位", options=df.columns)
|
72 |
y_column = st.selectbox("選擇 Y 軸欄位", options=numeric_columns)
|
73 |
|
74 |
+
# Chart type selection
|
|
|
75 |
chart_type = st.radio("選擇圖表類型", ("圓餅圖", "柱狀圖"))
|
76 |
|
77 |
+
# Button to trigger analysis
|
78 |
+
if st.button("分析數據"):
|
79 |
+
# Visualization
|
80 |
+
st.subheader("資料視覺化")
|
81 |
+
|
82 |
+
if chart_type == "圓餅圖":
|
83 |
+
fig = px.pie(df, names=x_column, values=y_column, title=f"{selected_option} 分佈")
|
84 |
+
else: # 柱狀圖
|
85 |
+
fig = px.bar(df, x=x_column, y=y_column, title=f"{selected_option} 比較")
|
86 |
+
|
87 |
+
# Apply custom font and styling to the plot
|
88 |
+
fig.update_layout(
|
89 |
+
font_family="Taipei Sans TC Beta",
|
90 |
+
title_font_size=24,
|
91 |
+
legend_title_font_size=14,
|
92 |
+
legend_font_size=12
|
93 |
+
)
|
94 |
+
|
95 |
+
# Display the chart
|
96 |
+
st.plotly_chart(fig, use_container_width=True)
|
97 |
else:
|
98 |
st.warning("沒有足夠的數值型欄位來創建圖表。請選擇另一個數據集。")
|
99 |
|