Skip to content

Stop the time labels colliding, and let them stand up - #37

Closed
evandhoffman wants to merge 2 commits into
window-totalsfrom
time-axis-labels
Closed

Stop the time labels colliding, and let them stand up#37
evandhoffman wants to merge 2 commits into
window-totalsfrom
time-axis-labels

Conversation

@evandhoffman

Copy link
Copy Markdown
Contributor

Stacked on #36 — based on window-totals, so this shows only its own commit.
GitHub retargets it to main when that merges.

From a screenshot: 08:52:3008:53:0008:53:30.

Three things were wrong at once

  • The room was measured off the chart, not the plot. A flat 50-point
    allowance stood in for the y-axis. That is right for one card and generous
    for every card whose numbers are long — and those are exactly the cards whose
    plots are narrowest. chartBackground hands over the real plot rect.
    Deliberately not chartOverlay: an overlay sits above the content and would
    swallow the mouse-down a tile's drag needs, which is the trap ReorderDrag
    already documents.
  • Every stride was costed at the same label width. A stride of a minute or
    more shows no seconds, so "8:52" needs a third less room than "8:52:30".
    Measured in SF Rounded at the new size: 20 points against 32. Budgeting the
    coarse strides at the wide figure left the axis unable to reach for the one a
    cramped card wanted.
  • The labels were wider than they needed to be. They get their own size now,
    smaller than the y-axis labels beside them — there are more of them, they are
    longer, and a y-axis label has a whole row to itself. The hour loses its
    leading zero; minutes and seconds keep both digits, because those are
    positional and "8:5:3" is not a time.

Rule 2 now beats rule 1

The old order was "never fewer than two labels" first, on the grounds that
slightly tight labels beat a bare axis. Right about "slightly tight", wrong
about what the arithmetic produced: four labels 32 points wide with their
centres 40 apart, overlapping outright at the narrowest card. Labels that
collide are unreadable, which is worse than the sparse axis the rule avoided.

Two labels are still what it reaches for — the walk goes finest first, so the
first stride that fits is the densest that fits. What is gone is the promise. A
narrow card showing two minutes has no stride both coarse enough to fit and fine
enough to guarantee two; it now shows one label rather than two on top of each
other.

Turning them sideways is how to have both

Turn the time labels sideways, new in the Charts tab, off by default. On its
side a label costs its line height rather than its width — 10 points against 32
— so the narrowest card fits four times where upright it fits two.

plot window upright sideways
130 2 min every 60 s, 2 labels every 30 s, 4 labels
130 10 min every 300 s, 2 labels every 120 s, 5 labels
160 2 min every 30 s, 4 labels every 30 s, 4 labels
260+ any unchanged unchanged

The card from the screenshot (160-point plot, 2 min) keeps its four labels and
gains 12 points of clear gutter between them.

Tests

ChartAxisTests is rewritten against the new contract, keeping every existing
claim (a tick is an instant, the interval comes from the window's length, ticks
are inset from the edges, the interval is stable as the window slides) and
adding the ones this bug needed:

  • Labels never overlap, swept across every window, six plot widths, both
    orientations and forty phases of each window — the ink two neighbouring
    labels need against the distance between them.
  • Two labels wherever two fit, and rotated, two outright.
  • Turning them never costs a label: a rotated stride is never coarser.
  • The screenshot's own case, as a named regression.

210 tests pass; swift build -c release and swiftformat --lint clean.

Not verified on screen

The arithmetic is tested, the appearance is not. The rotated label frame
(Theme.Layout.timeLabelRotated, 11 × 40) is the part most likely to want an
adjustment by eye.

https://claude.ai/code/session_01EqTTtmt4fyNtMxjc2ZVBzj

08:52:3008:53:0008:53:30. Three things were wrong at once.

The room was measured off the chart rather than the plot, with a flat
50-point allowance standing in for the y-axis — right for one card, and
generous for every card whose numbers are long, which are the cards whose
plots are narrowest. chartBackground hands over the real plot rect.
Not chartOverlay: an overlay would swallow the mouse-down a tile's drag
needs.

Every stride was costed at the same label width, though a stride of a
minute or more shows no seconds and needs a third less room. Measured, at
the new smaller label size, that is 20 points against 32. Budgeting the
coarse strides at the wide figure left the axis unable to reach for the
one a cramped card wanted.

And the labels were wider than they needed to be. They get their own size
now, smaller than the y-axis labels beside them, and the hour loses its
leading zero.

Rule 2 now beats rule 1. Slightly tight labels do beat a bare axis, but
these were not slightly tight, they were on top of each other. Two labels
are still what the walk reaches for; what is gone is the promise.

Turning them sideways is how a narrow card has both: on its side a label
costs its line height, 10 points against 32, so it fits four times where
upright it fits two.

Claude-Session: https://claude.ai/code/session_01EqTTtmt4fyNtMxjc2ZVBzj
@evandhoffman evandhoffman added enhancement New feature or request release:minor Merging this bumps the minor version labels Aug 28, 2026
@evandhoffman

Copy link
Copy Markdown
Contributor Author

Folded into #38, which carries this commit unchanged. Same reason as #36: stacked PRs are not independently reviewable, so the split cost releases and bought no review value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request release:minor Merging this bumps the minor version

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant