Fix chart accumulation bug: render daily balance instead of cumulative sum

This commit is contained in:
Dione
2026-06-10 20:05:58 +00:00
parent 88c8f7927d
commit e163f83963

View File

@ -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 = {