Roberta2024 commited on
Commit
d99ac8e
·
verified ·
1 Parent(s): b3daefd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -17
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
- # Visualization
75
- st.subheader("資料視覺化")
76
  chart_type = st.radio("選擇圖表類型", ("圓餅圖", "柱狀圖"))
77
 
78
- if chart_type == "圓餅圖":
79
- fig = px.pie(df, names=x_column, values=y_column, title=f"{selected_option} 分佈")
80
- else: # 柱狀圖
81
- fig = px.bar(df, x=x_column, y=y_column, title=f"{selected_option} 比較")
82
-
83
- # Apply custom font and styling to the plot
84
- fig.update_layout(
85
- font_family="Taipei Sans TC Beta",
86
- title_font_size=24,
87
- legend_title_font_size=14,
88
- legend_font_size=12
89
- )
90
-
91
- # Display the chart
92
- st.plotly_chart(fig, use_container_width=True)
 
 
 
 
 
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