Skip to content

fix(timeline): keep ruler labels from running into each other - #68

Merged
HalfSweet merged 3 commits into
mainfrom
fix/ruler-label-overlap
Oct 26, 2026
Merged

HalfSweet merged 3 commits into
mainfrom
fix/ruler-label-overlap

Conversation

@HalfSweet

Copy link
Copy Markdown
Owner

Deep into a long capture the ruler's labels ran into one another, and the first one covered the unit. Major ticks were kept at least 70 px apart whatever their labels said, but the labels grow with the time and with the decimals a fine step needs: 10.8 s into a capture at 10 ns a division they read like 10.80115195, which is 69 px of text in the bundled 11 px IBM Plex Sans (figures 6.6 px, the point 3 px, measured in Chrome), 75 px with its padding. Whether a given zoom level lands in that range depends on the window width and display scaling, so it showed on some computers only.

  • Space major ticks by the width of their labels: rulerTicks estimates the labels at both ends of the view and takes larger 1-2-5 steps until neighbouring labels keep 12 px of room. The overview strip shares the rule, and the time per division in the status bar follows the step (10 ns/div becomes 20 ns/div in the case above).
  • Leave out a label near the ruler's left edge by where its text begins, not where its tick is, so long labels no longer cover the unit; the tick mark stays.
  • Describe both in DESIGN.md §6.1.

Label widths are estimated from the bundled font's metrics (labelWidth in src/timeline/ticks.ts) rather than measured at run time; a change of the tick label font or size has to update them.

Validation:

  • pnpm exec eslint src
  • pnpm typecheck
  • pnpm test: 86 files, 609 tests passed, including new cases in ticks.test.ts (the reported state: 10.8 s at 100 MHz, 71 px for 10 ns) and TimelineRuler.test.ts (a label at 40 px that would cover the unit), which fail on the previous code
  • Not checked by hand in the running app: the demo device's captures are too short for labels this long; for labels up to about eight characters the steps are as before

Major ticks were kept at least 70 px apart however long their labels
were. Deep into a long capture the labels grow to many digits, such as
10.80115195 at 10 ns a division 10.8 s in, which is 69 px of text, so
at some zoom levels neighbouring labels ran into one another. Which
levels depends on the window width and display scaling, so it showed
on some computers only.

Measure the labels at both ends of the view in the ruler's font and
take larger 1-2-5 steps until they keep 12 px apart. The overview
strip shares the rule, and the time per division follows the step.
A major tick's label was left out near the ruler's left edge only when
its tick was within 32 px of it, wherever its text began, so a long
label such as 90.00000 covered the unit beside it.

Leave out a label when its text would begin within 28 px of the edge,
clear of the unit label 6 px in and at most 15 px wide; its mark stays.
DESIGN.md §6.1 now says that major ticks move further apart than 70 px
when their labels need it, and that a label that would cover the unit
is left out.
@HalfSweet
HalfSweet merged commit a584f1a into main Oct 26, 2026
3 checks passed
@github-actions github-actions Bot mentioned this pull request Oct 26, 2026
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.

1 participant