Skip to content

fix: lay out the daily trend on the calendar month - #395

Merged
chattymin merged 2 commits into
chattymin:mainfrom
heli-os:fix/month-trend-calendar-axis
Oct 5, 2026
Merged

chattymin merged 2 commits into
chattymin:mainfrom
heli-os:fix/month-trend-calendar-axis

Conversation

@heli-os

@heli-os heli-os commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Summary

On the 1st of the month the daily trend draws a single bar across the whole row (screenshot in the #348 discussion). The series runs from the 1st to today, and the view splits the row width across however many days it has. So during the first weeks, bar widths and the axis labels (1, 7, 14, …) move every day.

  • Add DailyTrendMetrics.monthColumns(series:today:), a pure function that returns one column per day of the calendar month and marks days after today as future. Only the view pads. monthDailySeries still ends today, as testSeriesStopsAtTodayAndNeverRunsToTheEndOfTheMonth pins, so UsageLedger.merge keeps treating a zero in the series as a real zero.
  • Future columns draw no bar, no weekend tick, and take no hover. The regular axis labels (1, 7, 14, 21, 28) stay in a dimmer color, so bars and labels keep their place all month. The rule that drops a regular label next to today now applies on both sides.
  • Weekend ticks stop at today. Under empty future columns they read as stray __ __ marks.
  • Days from another month stay off the axis. monthDailyTotals is the union of the providers' axes, so just after midnight a provider can still hold last month's series.
  • The caption hides "Peak" while only one day has usage. On the 1st it repeated the readout.

Following the discussion in #348: this overlaps that PR's bar row and caption, and we agreed to open it separately. Whichever lands second takes the rebase; I'm happy to do it on my side.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Documentation
  • Other:

UI changes

Popover Home tab, "Daily this month" row. Rendered from MonthDailyTrend at 2x with the same data on main and on this branch (dark popover background, 360pt width).

Before After
Oct 1 Before, Oct 1 After, Oct 1
Oct 3 Before, Oct 3 After, Oct 3
Korean UI
Before After
10/1 Before, Oct 1 (ko) After, Oct 1 (ko)
10/3 Before, Oct 3 (ko) After, Oct 3 (ko)
  • On the 1st, the single bar no longer fills the row. It takes the first of 31 columns, and the axis shows 1 (today), 7, 14, 21, 28.
  • Bar width and label positions stay fixed all month. Days after today are empty columns with dimmer labels; weekend ticks stop at today.
  • "Peak" appears once a second day has usage. On the 1st it repeated the readout.

Checklist

  • swift build and swift test pass locally: swift build passes locally. This machine has only Command Line Tools (no XCTest), so the full suite ran in CI instead: 1390 tests, 0 failures, coverage gate passed (run).
  • PR title and description are written in English
  • UI changes are described above (before/after — images optional)
  • No copyrighted assets, secrets, or private tooling references are committed (see CONTRIBUTING)
  • Tests were added or updated for this change

Tests in MonthDailyTrendTests:

  • New: column count equals the days in the month, including on the 1st, February in a leap year, and months where DST changes. Days after today are future, and missing past days are zero. Days from another month stay off the axis. The peak shows only once two days have usage. Weekend ticks stop at today. The 1st renders the same row height as mid-month.
  • Updated: the axis label tests now count labels over the full month's columns, as the view does. The cap of six labels and the no-adjacent-labels rule are checked for every day of the month.

🤖 Generated with Claude Code

heli-os and others added 2 commits October 1, 2026 10:18
The daily trend split the row width across the days in the series, and
the series ends today. On the 1st a single bar filled the whole row, and
during the first weeks bar widths and axis labels moved every day.

- Add DailyTrendMetrics.monthColumns(series:today:): one column per day of
  the calendar month, with days after today marked as future. The view
  pads; the data series still ends today, so the recap ledger keeps
  treating a zero in the series as a real zero.
- Future columns draw no bar and take no hover. Weekend ticks and the
  regular axis labels stay, so bars and labels keep their place all month.
- Days from another month (a provider still holding last month's series
  just after midnight) stay off the axis.
- Hide the caption's peak while only one day has usage, where it repeats
  the readout.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
With the axis spanning the whole month, weekend ticks under future
columns had no bar above them and read as stray "__ __" marks. Draw
them only for past days and today.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@chattymin
chattymin merged commit 0269dad into chattymin:main Oct 5, 2026
2 checks passed
LuceteYang added a commit to LuceteYang/PikaTokenBar that referenced this pull request Oct 5, 2026
Resolve the PopoverView conflict with chattymin#395 (calendar-month trend axis):
the stacked bars and hover tooltip now iterate the month columns, leave
future days as empty placeholders, and position the tooltip by column.
donky-ey pushed a commit to donky-ey/PokeDexBar that referenced this pull request Oct 15, 2026
…n#395)

The daily trend split the row width across the days in the series, and
the series ends today. On the 1st a single bar filled the whole row, and
during the first weeks bar widths and axis labels moved every day.
DailyTrendMetrics.monthColumns pads one column per calendar day; future
columns draw no bar and take no hover, and days from another month stay
off the axis.
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.

2 participants