Skip to content

fix: separate star chart x labels on short windows - #730

Merged
av1155 merged 2 commits into
mainfrom
fix/star-history-short-window-labels
Aug 11, 2026
Merged

fix: separate star chart x labels on short windows#730
av1155 merged 2 commits into
mainfrom
fix/star-history-short-window-labels

Conversation

@av1155

@av1155 av1155 commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Summary

The chart's x-axis tick format was chosen like this:

tick_format = "%b %d" if first.year == last.year else "%b %Y"

X_TICKS is fixed at 5 and the ticks are spread evenly across the window, so
what decides whether two of them collide is the gap between them. A calendar
year comparison says nothing about that gap, and it fails in both directions:
short windows collapse under %b %d, and a short window that happens to
straddle 31 December is pushed all the way to %b %Y, which cannot separate
ticks a few days apart.

Measured against the current renderer, reading the x-tick row:

Window Rendered Distinct
2 hours Aug 01 five times 1/5
1 day Aug 01 four times, Aug 02 2/5
3 days Aug 01, Aug 01, Aug 02, Aug 03, Aug 04 4/5
7 days from 28 Dec Dec 2026 three times, Jan 2027 twice 2/5
15 Dec to 15 Feb Dec 2026, Dec 2026, Jan 2027, Jan 2027, Feb 2027 3/5
same instant Jan 01 five times 1/5

Closes #725

Changes

  • _x_tick_format picks the coarsest format that still separates adjacent
    ticks, from the gap between them: month and year at a year or more, day below
    that, dropping to hours and then seconds as the gap shrinks.
  • A window under a second wide renders one tick instead of five. No format can
    separate ticks that are the same instant, and _scale_x already stacks them
    on a single pixel, so five copies was the wrong answer rather than a
    formatting problem.

The 7-days-across-New-Year case now reads Dec 28, Dec 29, Dec 31, Jan 02, Jan 04, which is both distinct and more useful than the month labels it produced
before.

Testing

Full gate green: 2806 passed.

The three new tests were run against the pre-fix renderer first and all three
fail there, which is the point of them:

FAILED tests/test_star_history.py::TestRender::test_date_labels_are_unique_on_short_windows
FAILED tests/test_star_history.py::TestRender::test_short_windows_crossing_a_year_keep_day_resolution
FAILED tests/test_star_history.py::TestRender::test_a_window_of_zero_renders_one_tick

Two properties worth calling out, both checked rather than assumed:

  • The existing year-boundary test is untouched and still passes. Its spans
    (200 to 3000 days) select the same formats as before.
  • The live chart does not change. Rendering the real 264-star data through
    both the old and new renderer gives byte-identical SVGs, and both match what
    is currently published on assets. That matters because the workflow treats
    an unchanged render as a no-op, so a format change would have pushed one
    pointless refresh commit.

Type of Change

  • Bug fix (fix:)
  • New feature (feat:)
  • Refactoring (refactor:)
  • Documentation (docs:)
  • CI/CD (ci:)
  • Chore (chore:)

Checklist

  • Issue exists and is linked above with Closes #N
  • Linked issue has exactly one type:* and one priority:* label
  • Linked issue has at most one phase:* label (or none when not roadmap work)
  • Branch name matches issue scope (feat/<slug>, fix/<slug>, etc.)
  • Tests added/updated for all changes
  • Type check passes (mypy src/; the script is clean under it too)
  • Lint passes (ruff check .)
  • Format passes (ruff format --check .)
  • Documentation updated (if applicable) — N/A
  • No secrets or sensitive data committed
  • Scope check: This change helps search for missing or cutoff-unmet media in a controlled way — N/A, README chart renderer

av1155 added 2 commits August 11, 2026 13:07
The tick format was chosen from whether the first and last star fell
in the same calendar year, which says nothing about how far apart the
ticks are. A two-hour window printed one date five times, and a week
straddling 31 December was pushed to month resolution it could not
separate. Pick the format from the gap between ticks instead, and
draw a single tick when they all land on one instant.

Closes #725
@av1155
av1155 merged commit 54244a4 into main Aug 11, 2026
20 checks passed
@av1155
av1155 deleted the fix/star-history-short-window-labels branch August 11, 2026 17:22
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.

fix: star history chart duplicates x-axis labels on short windows

1 participant