Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -187,14 +187,38 @@ with tab2:
|
|
| 187 |
# Biểu diễn trực quan
|
| 188 |
if not df_income.empty:
|
| 189 |
st.subheader("📈 Biểu đồ doanh thu và lợi nhuận")
|
| 190 |
-
|
| 191 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 192 |
|
| 193 |
if revenue_cols and profit_cols:
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 198 |
|
| 199 |
except Exception as e:
|
| 200 |
st.error(f"❌ Lỗi dữ liệu tài chính: {e}")
|
|
|
|
| 187 |
# Biểu diễn trực quan
|
| 188 |
if not df_income.empty:
|
| 189 |
st.subheader("📈 Biểu đồ doanh thu và lợi nhuận")
|
| 190 |
+
|
| 191 |
+
# Hiển thị tên các cột để debug
|
| 192 |
+
revenue_keywords = ['doanh thu', 'thu nhập', 'revenue', 'income']
|
| 193 |
+
profit_keywords = ['lợi nhuận', 'lãi', 'profit', 'earnings', 'lnst']
|
| 194 |
+
|
| 195 |
+
revenue_cols = []
|
| 196 |
+
for keyword in revenue_keywords:
|
| 197 |
+
revenue_cols.extend([col for col in df_income.columns if keyword in col.lower()])
|
| 198 |
+
revenue_cols = list(set(revenue_cols)) # Loại bỏ trùng lặp
|
| 199 |
+
|
| 200 |
+
profit_cols = []
|
| 201 |
+
for keyword in profit_keywords:
|
| 202 |
+
profit_cols.extend([col for col in df_income.columns if keyword in col.lower()])
|
| 203 |
+
profit_cols = list(set(profit_cols)) # Loại bỏ trùng lặp
|
| 204 |
|
| 205 |
if revenue_cols and profit_cols:
|
| 206 |
+
# Tạo button để force refresh biểu đồ
|
| 207 |
+
if st.button("Hiển thị biểu đồ", key="show_finance_chart"):
|
| 208 |
+
fig_finance = go.Figure()
|
| 209 |
+
fig_finance.add_trace(go.Bar(x=df_income.index, y=df_income[revenue_cols[0]], name='Doanh thu'))
|
| 210 |
+
fig_finance.add_trace(go.Bar(x=df_income.index, y=df_income[profit_cols[0]], name='Lợi nhuận'))
|
| 211 |
+
fig_finance.update_layout(
|
| 212 |
+
title='Biểu đồ doanh thu và lợi nhuận',
|
| 213 |
+
xaxis_title='Kỳ báo cáo',
|
| 214 |
+
yaxis_title='Giá trị (VND)',
|
| 215 |
+
barmode='group'
|
| 216 |
+
)
|
| 217 |
+
st.plotly_chart(fig_finance, use_container_width=True)
|
| 218 |
+
else:
|
| 219 |
+
st.warning("Không tìm thấy cột doanh thu hoặc lợi nhuận trong dữ liệu. Vui lòng kiểm tra lại nguồn dữ liệu.")
|
| 220 |
+
else:
|
| 221 |
+
st.warning("Không có dữ liệu báo cáo tài chính.")
|
| 222 |
|
| 223 |
except Exception as e:
|
| 224 |
st.error(f"❌ Lỗi dữ liệu tài chính: {e}")
|