From ab41d5a73da99bd727cb97a83df25f0a4be9fbdc Mon Sep 17 00:00:00 2001 From: icy Date: Tue, 4 Nov 2025 01:54:21 +0800 Subject: [PATCH] Fix ComparisonChart data display issue MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The chart was not showing data because the API response format changed. Fixed the calculation of PnL percentage by computing it from total_pnl and balance values (initial_balance = balance - total_pnl). Now the AI competition chart should properly display performance comparison data. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: tinkle-community --- web/src/components/ComparisonChart.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/web/src/components/ComparisonChart.tsx b/web/src/components/ComparisonChart.tsx index 56810e0e..600421a3 100644 --- a/web/src/components/ComparisonChart.tsx +++ b/web/src/components/ComparisonChart.tsx @@ -92,8 +92,13 @@ export function ComparisonChart({ traders }: ComparisonChartProps) { }); } + // 计算盈亏百分比:从total_pnl和balance计算 + // 假设初始余额 = balance - total_pnl + const initialBalance = point.balance - point.total_pnl; + const pnlPct = initialBalance > 0 ? (point.total_pnl / initialBalance) * 100 : 0; + timestampMap.get(ts)!.traders.set(trader.trader_id, { - pnl_pct: point.total_pnl_pct, + pnl_pct: pnlPct, equity: point.total_equity }); });