Skip to content

fix(charts): prevent cross-year day bucket collisions in History and Dashboard (#29, #47) - #88

Open
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/history-chart-year-bucketing
Open

fix(charts): prevent cross-year day bucket collisions in History and Dashboard (#29, #47)#88
ghzhost wants to merge 1 commit into
StellarSend:mainfrom
ghzhost:fix/history-chart-year-bucketing

Conversation

@ghzhost

@ghzhost ghzhost commented Sep 2, 2026

Copy link
Copy Markdown

Description

This PR fixes issue #29 (and resolves duplicate aggregation logic from #47) where transactions on the same month and day in different calendar years collided and summed into the same 30-day / 7-day chart buckets.

Root Cause

Previously, History.tsx (HistoryChart) and Dashboard.tsx (ActivityChart) built bucket keys using only the formatted locale month and day string:

const key = d.toLocaleDateString('en-US', { month: 'short', day: 'numeric' }) // e.g. 'Aug 15'

When historical data spanned multiple years or occurred around year boundaries, transactions from an earlier year with matching month/day (e.g., 2025-08-15 vs 2026-08-15) matched days[key] and incorrectly aggregated into the current window's bucket.

Solution

  1. Extracted chart data aggregation into dedicated utilities in src/utils/chart.ts:
    • getHistoryChartData(transactions, now)
    • getActivityChartData(transactions, now)
  2. Indexed internal buckets by canonical YYYY-MM-DD (toUtcDateKey(date)), preventing cross-year key collisions while preserving formatted MMM D display labels for chart axes and tooltips.
  3. Added comprehensive unit tests in src/utils/chart.test.ts covering cross-year isolation, 30-day and 7-day window sizes, and accurate volume / fee calculation.

Closes #29
Resolves #47

…Dashboard (StellarSend#29, StellarSend#47)

- Extract shared chart aggregation utilities to src/utils/chart.ts (getHistoryChartData and getActivityChartData).
- Key day buckets using normalized UTC YYYY-MM-DD keys so transactions on the same month/day in different years never collide.
- Keep locale-formatted display strings ('MMM D') for chart axes and tooltips.
- Add comprehensive test suite in src/utils/chart.test.ts validating cross-year separation and metric aggregations.
- Fixes StellarSend#29 and resolves StellarSend#47 duplication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant