From e163f83963a6025aa9907b12119f105291509807 Mon Sep 17 00:00:00 2001 From: Dione Date: Wed, 10 Jun 2026 20:05:58 +0000 Subject: [PATCH] Fix chart accumulation bug: render daily balance instead of cumulative sum --- index.html | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/index.html b/index.html index a268ea0..aa9f1a1 100644 --- a/index.html +++ b/index.html @@ -1235,12 +1235,13 @@ function buildCumulativeSeries(addresses) { const tsB = new Date(b.dateStr).getTime(); return tsA - tsB; }); - let cumul = 0; - return sorted.map(d => { - cumul += d.total; - const dateStr = d.dateStr; - return [new Date(dateStr).getTime(), cumul]; + const byDate = new Map(); + sorted.forEach(d => { + if (!byDate.has(d.dateStr)) { + byDate.set(d.dateStr, d); + } }); + return Array.from(byDate.values()).map(d => [new Date(d.dateStr).getTime(), d.total]); } function calculateAggregatedSeries() { @@ -1656,15 +1657,11 @@ function setupBreakdownCard(cutoff) { }); }); const entries = Object.keys(dayMap).map(ts => parseInt(ts)).sort((a, b) => a - b); - let c0 = 0, c1 = 0; const totalSeries = entries.map(ts => { - c0 += dayMap[ts].cold + dayMap[ts].collateral; - return [ts, c0]; + return [ts, dayMap[ts].cold + dayMap[ts].collateral]; }).filter(d => d[0] >= cutoff); - let c2 = 0; const aaveSeries = entries.map(ts => { - c2 += dayMap[ts].collateral; - return [ts, c2]; + return [ts, dayMap[ts].collateral]; }).filter(d => d[0] >= cutoff); const opts = {