Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,4 +1,3 @@
|
|
1 |
-
# -*- coding: utf-8 -*-
|
2 |
import streamlit as st
|
3 |
import pandas as pd
|
4 |
import requests
|
@@ -61,13 +60,15 @@ if st.button("生成圖表"):
|
|
61 |
|
62 |
with tab1:
|
63 |
# 使用 plotly 創建圓餅圖
|
64 |
-
fig_pie = px.pie(selected_df, names=
|
65 |
title=f"{dataset_choice} - {column_choice} 圓餅圖",
|
66 |
color_discrete_sequence=px.colors.qualitative.Pastel)
|
67 |
fig_pie.update_traces(textposition='inside', textinfo='percent+label')
|
68 |
fig_pie.update_layout(
|
69 |
-
font=dict(size=
|
70 |
-
legend=dict(orientation="h", yanchor="bottom", y
|
|
|
|
|
71 |
)
|
72 |
st.plotly_chart(fig_pie, use_container_width=True)
|
73 |
|
@@ -75,14 +76,15 @@ if st.button("生成圖表"):
|
|
75 |
# 使用 plotly 創建長條圖
|
76 |
fig_bar = px.bar(selected_df, x='公司名稱', y=column_choice,
|
77 |
title=f"{dataset_choice} - {column_choice} 長條圖",
|
78 |
-
color='公司名稱',
|
79 |
color_discrete_sequence=px.colors.qualitative.Pastel)
|
80 |
fig_bar.update_layout(
|
81 |
xaxis_title="企業",
|
82 |
yaxis_title=column_choice,
|
83 |
-
font=dict(size=
|
84 |
xaxis_tickangle=-45,
|
85 |
-
showlegend=False
|
|
|
86 |
)
|
87 |
st.plotly_chart(fig_bar, use_container_width=True)
|
88 |
|
|
|
|
|
1 |
import streamlit as st
|
2 |
import pandas as pd
|
3 |
import requests
|
|
|
60 |
|
61 |
with tab1:
|
62 |
# 使用 plotly 創建圓餅圖
|
63 |
+
fig_pie = px.pie(selected_df, names='公司名稱', values=column_choice,
|
64 |
title=f"{dataset_choice} - {column_choice} 圓餅圖",
|
65 |
color_discrete_sequence=px.colors.qualitative.Pastel)
|
66 |
fig_pie.update_traces(textposition='inside', textinfo='percent+label')
|
67 |
fig_pie.update_layout(
|
68 |
+
font=dict(size=12),
|
69 |
+
legend=dict(orientation="h", yanchor="bottom", y=-0.5, xanchor="center", x=0.5),
|
70 |
+
height=700, # 增加圖表高度
|
71 |
+
margin=dict(t=100, b=100) # 增加上下邊距
|
72 |
)
|
73 |
st.plotly_chart(fig_pie, use_container_width=True)
|
74 |
|
|
|
76 |
# 使用 plotly 創建長條圖
|
77 |
fig_bar = px.bar(selected_df, x='公司名稱', y=column_choice,
|
78 |
title=f"{dataset_choice} - {column_choice} 長條圖",
|
79 |
+
color='公司名稱',
|
80 |
color_discrete_sequence=px.colors.qualitative.Pastel)
|
81 |
fig_bar.update_layout(
|
82 |
xaxis_title="企業",
|
83 |
yaxis_title=column_choice,
|
84 |
+
font=dict(size=12),
|
85 |
xaxis_tickangle=-45,
|
86 |
+
showlegend=False,
|
87 |
+
height=600 # 增加圖表高度
|
88 |
)
|
89 |
st.plotly_chart(fig_bar, use_container_width=True)
|
90 |
|