Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -57,13 +57,18 @@ if st.button("載入資料"):
|
|
57 |
st.header(f"{selected_option} 資料")
|
58 |
st.dataframe(df)
|
59 |
|
60 |
-
#
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
|
|
|
|
|
|
|
|
|
|
67 |
|
68 |
# Apply custom font to the plot
|
69 |
fig.update_layout(font_family="Taipei Sans TC Beta")
|
|
|
57 |
st.header(f"{selected_option} 資料")
|
58 |
st.dataframe(df)
|
59 |
|
60 |
+
# Column selection for visualization
|
61 |
+
x_col = st.selectbox("選擇類別欄位 (X 軸)", options=df.columns)
|
62 |
+
y_col = st.selectbox("選擇數值欄位 (Y 軸)", options=df.columns)
|
63 |
+
|
64 |
+
# Chart type selection
|
65 |
+
chart_type = st.radio("選擇圖表類型", ("圓餅圖", "柱狀圖"))
|
66 |
+
|
67 |
+
# Plotting the data based on user selection
|
68 |
+
if chart_type == "圓餅圖":
|
69 |
+
fig = px.pie(df, names=x_col, values=y_col, title=f"Pie Chart for {selected_option}")
|
70 |
+
elif chart_type == "柱狀圖":
|
71 |
+
fig = px.bar(df, x=x_col, y=y_col, title=f"Bar Chart for {selected_option}")
|
72 |
|
73 |
# Apply custom font to the plot
|
74 |
fig.update_layout(font_family="Taipei Sans TC Beta")
|