Skip to content

Align Cash Balance Trend timeframes to the calendar - #184

Merged
31b4 merged 1 commit into
mainfrom
bug/183-cash-trend-timeframes
Oct 28, 2026
Merged

31b4 merged 1 commit into
mainfrom
bug/183-cash-trend-timeframes

Conversation

@31b4

@31b4 31b4 commented Oct 28, 2026

Copy link
Copy Markdown
Member

Closes #183

Summary

The Cash Balance Trend chart (Analytics page) now labels its x-axis on calendar boundaries, starts monthly views on the 1st, offers a previous-year comparison in 1Y, and keeps the card the same height when the comparison or privacy mode is toggled, so the toggle no longer moves under the pointer.

Changes

  • Calendar ticks (common/calendar-ticks.ts, opt-in calendarAxis on InteractiveAreaChart): picks the finest calendar unit whose labels fit the plot width. That gives days (1M), months (1Y), and quarters, half-years or years (All). Labels are placed by time, not by data index. Multi-year spans name January by its year (for example 2025, Apr, Jul, Oct, 2026…). Other charts that use InteractiveAreaChart keep their current labels.
  • Period clipping (analytics-module/cash-balance-trend.ts): 1M opens on the 1st with the carried balance and fills quiet days through today, or through month end for past months. 1Y opens on Jan 1 the same way. A carried balance is used only when earlier history covers it; pre-ledger balances are never invented.
  • Compare previous year: the comparison builder now takes a unit (month | year) and aligns year slots by month and day. A Feb 29 slot with no match is null on the other side. It uses the same availability rules (full previous-period history, current/past periods, Actual mode only) and the same masked tooltip. The result fields are renamed selectedStart/previousStart and gain unit.
  • Stable layout: the comparison view and the privacy-hidden view now use the same readout, plot-height and legend/footer rows as the trend chart. The readout caption is a single line. The toggle keeps its label (Compare previous month/year, shown as pressed when on), and Trend keeps its slot while comparing.

Verification

  • npm test -w client: 60 files, all passed. New tests cover tick generation (month/year/multi-year at desktop and mobile widths), month-start padding and clipping, year comparison (alignment, Feb 29, coverage) and layout slots/privacy masking.
  • npm run lint -w client -- --max-warnings=0: clean.
  • VITE_API_AUTH_MODE=public VITE_API_DOMAIN=localhost:8787 npm run build: built.
  • Manual check against a local API with two years of synthetic data (no transaction on the 1st of the current month):
    • Desktop (1400px) ticks: 1M Oct 1, 4 … 25; 1Y Jan … Oct; All 2025 Apr Jul Oct 2026 Apr Jul Oct.
    • Mobile (375px) ticks: 1M Oct 1, 8, 15, 22; 1Y Jan Mar May Jul Sep; All 2025 Jul 2026 Jul. No horizontal page scroll.
    • Card height and compare-button position were identical with comparison off and on for 1M and 1Y, on desktop, on mobile, and in privacy-hidden mode.
    • Checked in dark and light themes.

Label month, year and all-time views on calendar days, months, quarters
or years that fit the chart width. Start month views on the 1st with the
carried opening balance when earlier history covers it, and open year
views on January 1 the same way.

Add Compare previous year for the year view, reusing the monthly
comparison builder with month/day-aligned slots. Give the comparison and
privacy views the same readout, plot and legend rows as the trend chart
and keep the toggle label fixed, so switching views never changes the
card height or moves the toggle.
@31b4
31b4 merged commit cb4c5d6 into main Oct 28, 2026
10 checks passed
@31b4
31b4 deleted the bug/183-cash-trend-timeframes branch October 28, 2026 07:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cash Balance Trend timeframes use arbitrary ticks, skip month start and shift on compare

1 participant