Upload app.py
Browse files
app.py
CHANGED
|
@@ -1261,8 +1261,8 @@ def build_income_table(table_data):
|
|
| 1261 |
|
| 1262 |
for j, cell in enumerate(row):
|
| 1263 |
if j == 0:
|
| 1264 |
-
# Category列样式
|
| 1265 |
-
cells += f"<td style='padding: 8px; border: 1px solid #ddd; text-align:
|
| 1266 |
else:
|
| 1267 |
# 添加增长率箭头(如果有的话)
|
| 1268 |
growth = None
|
|
@@ -1275,35 +1275,27 @@ def build_income_table(table_data):
|
|
| 1275 |
if growth and growth != "N/A" and growth != "--":
|
| 1276 |
arrow = "▲" if growth.startswith("+") else "▼"
|
| 1277 |
color = "green" if growth.startswith("+") else "red"
|
| 1278 |
-
# 年份数据列,包含增幅指示
|
| 1279 |
-
cells += f"""<td style='padding: 8px; border: 1px solid #ddd; text-align: center; font-size:
|
| 1280 |
-
<div
|
| 1281 |
-
<div style='position: absolute; bottom:
|
| 1282 |
-
</td>"""
|
| 1283 |
-
elif growth == "--":
|
| 1284 |
-
# 显示"--"但不显示箭头
|
| 1285 |
-
cells += f"""<td style='padding: 8px; border: 1px solid #ddd; text-align: center; font-size: 13px; position: relative;'>
|
| 1286 |
-
<div style='margin-bottom: 12px;'>{cell}</div>
|
| 1287 |
-
<div style='position: absolute; bottom: 2px; right: 5px; font-size: 10px; color: #999;'>--</div>
|
| 1288 |
</td>"""
|
| 1289 |
else:
|
| 1290 |
# 无增幅的单元格
|
| 1291 |
-
cells += f"<td style='padding: 8px; border: 1px solid #ddd; text-align: center; font-size:
|
| 1292 |
table_rows += f"<tr style='{row_style}'>{cells}</tr>"
|
| 1293 |
|
| 1294 |
html = f"""
|
| 1295 |
-
<div style="min-width: 400px;max-width: 600px;height: 300px !important;border: 1px solid #
|
| 1296 |
-
<div style="display: flex; align-items: center; gap:
|
| 1297 |
-
<svg width="
|
| 1298 |
-
<path d="M12 2L15.09 8.26L19 9.07L16 14L16 19L12 19L8 14L8 9.07L4.91 8.26L8 2L12 2Z" fill="#
|
| 1299 |
</svg>
|
| 1300 |
-
<div style="font-size:
|
| 1301 |
-
</div>
|
| 1302 |
-
<div style="overflow-x: auto;">
|
| 1303 |
-
<table style="width: 100%; border-collapse: collapse; font-size: 13px;">
|
| 1304 |
-
{table_rows}
|
| 1305 |
-
</table>
|
| 1306 |
</div>
|
|
|
|
|
|
|
|
|
|
| 1307 |
</div>
|
| 1308 |
"""
|
| 1309 |
return html
|
|
@@ -1363,18 +1355,18 @@ def create_metrics_dashboard():
|
|
| 1363 |
prev_close_val = company_info.get("previous_close", "N/A")
|
| 1364 |
|
| 1365 |
html = f"""
|
| 1366 |
-
<div style="width: 250px; height: 300px !important; border: 1px solid #
|
| 1367 |
-
<div style="font-size:
|
| 1368 |
-
<div style="font-size: 12px; color: #
|
| 1369 |
-
<div style="display: flex; align-items:
|
| 1370 |
-
<div style="font-size:
|
| 1371 |
-
<div style="font-size:
|
| 1372 |
</div>
|
| 1373 |
-
<div style="
|
| 1374 |
-
<div style="color: #
|
| 1375 |
-
<div style="color: #
|
| 1376 |
-
<div style="color: #
|
| 1377 |
-
<div style="color: #
|
| 1378 |
</div>
|
| 1379 |
</div>
|
| 1380 |
"""
|
|
@@ -1435,15 +1427,15 @@ def create_metrics_dashboard():
|
|
| 1435 |
"""
|
| 1436 |
|
| 1437 |
html = f"""
|
| 1438 |
-
<div style="min-width: 300px;max-width: 450px;height: 300px !important;border: 1px solid #
|
| 1439 |
-
<div style="display: flex; align-items: center; gap:
|
| 1440 |
-
<div style="font-size:
|
| 1441 |
-
<svg width="
|
| 1442 |
-
<path d="M12 2L15.09 8.26L19 9.07L16 14L16 19L12 19L8 14L8 9.07L4.91 8.26L8 2L12 2Z" fill="#
|
| 1443 |
</svg>
|
| 1444 |
<span style="margin-left: 10px;">{default_yearly_data} Financial Metrics</span>
|
| 1445 |
</div>
|
| 1446 |
-
<div style="font-size:
|
| 1447 |
YTD data
|
| 1448 |
</div>
|
| 1449 |
</div>
|
|
@@ -1621,15 +1613,15 @@ def update_metrics_dashboard(company_name):
|
|
| 1621 |
"""
|
| 1622 |
|
| 1623 |
html = f"""
|
| 1624 |
-
<div style="width: 450px;height: 300px !important;border: 1px solid #
|
| 1625 |
-
<div style="display: flex; align-items: center; gap:
|
| 1626 |
-
<div style="font-size:
|
| 1627 |
-
<svg width="
|
| 1628 |
-
<path d="M12 2L15.09 8.26L19 9.07L16 14L16 19L12 19L8 14L8 9.07L4.91 8.26L8 2L12 2Z" fill="#
|
| 1629 |
</svg>
|
| 1630 |
<span style="margin-left: 10px;">{yearly_data} Financial Metrics</span>
|
| 1631 |
</div>
|
| 1632 |
-
<div style="font-size:
|
| 1633 |
YTD data
|
| 1634 |
</div>
|
| 1635 |
</div>
|
|
|
|
| 1261 |
|
| 1262 |
for j, cell in enumerate(row):
|
| 1263 |
if j == 0:
|
| 1264 |
+
# Category列样式 - 恢复为居中
|
| 1265 |
+
cells += f"<td style='padding: 8px; border: 1px solid #ddd; text-align: center; font-size: 14px;'>{cell}</td>"
|
| 1266 |
else:
|
| 1267 |
# 添加增长率箭头(如果有的话)
|
| 1268 |
growth = None
|
|
|
|
| 1275 |
if growth and growth != "N/A" and growth != "--":
|
| 1276 |
arrow = "▲" if growth.startswith("+") else "▼"
|
| 1277 |
color = "green" if growth.startswith("+") else "red"
|
| 1278 |
+
# 年份数据列,包含增幅指示 - 恢复为不分离的版本
|
| 1279 |
+
cells += f"""<td style='padding: 8px; border: 1px solid #ddd; text-align: center; font-size: 14px; position: relative;'>
|
| 1280 |
+
<div>{cell}</div>
|
| 1281 |
+
<div style='position: absolute; bottom: -5px; right: 5px; font-size: 10px; color: {color};'>{arrow}{growth}</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1282 |
</td>"""
|
| 1283 |
else:
|
| 1284 |
# 无增幅的单元格
|
| 1285 |
+
cells += f"<td style='padding: 8px; border: 1px solid #ddd; text-align: center; font-size: 14px;'>{cell}</td>"
|
| 1286 |
table_rows += f"<tr style='{row_style}'>{cells}</tr>"
|
| 1287 |
|
| 1288 |
html = f"""
|
| 1289 |
+
<div style="min-width: 400px;max-width: 600px;height: 300px !important;border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-family: 'Segoe UI', sans-serif;">
|
| 1290 |
+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 16px;">
|
| 1291 |
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 1292 |
+
<path d="M12 2L15.09 8.26L19 9.07L16 14L16 19L12 19L8 14L8 9.07L4.91 8.26L8 2L12 2Z" fill="#0066cc"/>
|
| 1293 |
</svg>
|
| 1294 |
+
<div style="font-size: 18px; font-weight: 600;">Latest 3 Years Financial Metrics</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1295 |
</div>
|
| 1296 |
+
<table style="width: 100%; border-collapse: collapse; font-size: 14px;">
|
| 1297 |
+
{table_rows}
|
| 1298 |
+
</table>
|
| 1299 |
</div>
|
| 1300 |
"""
|
| 1301 |
return html
|
|
|
|
| 1355 |
prev_close_val = company_info.get("previous_close", "N/A")
|
| 1356 |
|
| 1357 |
html = f"""
|
| 1358 |
+
<div style="width: 250px; height: 300px !important; border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-family: 'Segoe UI', sans-serif;">
|
| 1359 |
+
<div style="font-size: 16px; color: #555; font-weight: 500;">{company_name}</div>
|
| 1360 |
+
<div style="font-size: 12px; color: #888;">NYSE:{symbol}</div>
|
| 1361 |
+
<div style="display: flex; align-items: center; gap: 10px; margin: 8px 0;">
|
| 1362 |
+
<div style="font-size: 32px; font-weight: bold;">{price}</div>
|
| 1363 |
+
<div style="font-size: 14px;">{change_html}</div>
|
| 1364 |
</div>
|
| 1365 |
+
<div style="margin-top: 12px; display: grid; grid-template-columns: auto 1fr; gap: 8px;">
|
| 1366 |
+
<div style="font-size: 14px; color: #555;">Open</div><div style="font-size: 14px; font-weight: 500; text-align: center;">{open_val}</div>
|
| 1367 |
+
<div style="font-size: 14px; color: #555;">High</div><div style="font-size: 14px; font-weight: 500; text-align: center;">{high_val}</div>
|
| 1368 |
+
<div style="font-size: 14px; color: #555;">Low</div><div style="font-size: 14px; font-weight: 500; text-align: center;">{low_val}</div>
|
| 1369 |
+
<div style="font-size: 14px; color: #555;">Prev Close</div><div style="font-size: 14px; font-weight: 500; text-align: center;">{prev_close_val}</div>
|
| 1370 |
</div>
|
| 1371 |
</div>
|
| 1372 |
"""
|
|
|
|
| 1427 |
"""
|
| 1428 |
|
| 1429 |
html = f"""
|
| 1430 |
+
<div style="min-width: 300px;max-width: 450px;height: 300px !important;border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-family: 'Segoe UI', sans-serif;">
|
| 1431 |
+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 16px;justify-content: space-between;">
|
| 1432 |
+
<div style="font-size: 18px; font-weight: 600;display: flex;align-items: center;">
|
| 1433 |
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 1434 |
+
<path d="M12 2L15.09 8.26L19 9.07L16 14L16 19L12 19L8 14L8 9.07L4.91 8.26L8 2L12 2Z" fill="#0066cc"/>
|
| 1435 |
</svg>
|
| 1436 |
<span style="margin-left: 10px;">{default_yearly_data} Financial Metrics</span>
|
| 1437 |
</div>
|
| 1438 |
+
<div style="font-size: 16px; color: #8f8f8f;">
|
| 1439 |
YTD data
|
| 1440 |
</div>
|
| 1441 |
</div>
|
|
|
|
| 1613 |
"""
|
| 1614 |
|
| 1615 |
html = f"""
|
| 1616 |
+
<div style="width: 450px;height: 300px !important;border: 1px solid #e0e0e0; border-radius: 8px; padding: 16px; box-shadow: 0 2px 4px rgba(0,0,0,0.1); font-family: 'Segoe UI', sans-serif;">
|
| 1617 |
+
<div style="display: flex; align-items: center; gap: 8px; margin-bottom: 16px;justify-content: space-between;">
|
| 1618 |
+
<div style="font-size: 18px; font-weight: 600;display: flex;align-items: center;">
|
| 1619 |
+
<svg width="16" height="16" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
|
| 1620 |
+
<path d="M12 2L15.09 8.26L19 9.07L16 14L16 19L12 19L8 14L8 9.07L4.91 8.26L8 2L12 2Z" fill="#0066cc"/>
|
| 1621 |
</svg>
|
| 1622 |
<span style="margin-left: 10px;">{yearly_data} Financial Metrics</span>
|
| 1623 |
</div>
|
| 1624 |
+
<div style="font-size: 16px; color: #8f8f8f;">
|
| 1625 |
YTD data
|
| 1626 |
</div>
|
| 1627 |
</div>
|