Skip to content

fix(dashboard): let the hourly chart's hour labels rotate instead of overlapping - #172

Open
DiegoDAF wants to merge 1 commit into
phuryn:DEVfrom
DiegoDAF:fix/hourly-axis-label-rotation
Open

fix(dashboard): let the hourly chart's hour labels rotate instead of overlapping#172
DiegoDAF wants to merge 1 commit into
phuryn:DEVfrom
DiegoDAF:fix/hourly-axis-label-rotation

Conversation

@DiegoDAF

Copy link
Copy Markdown

The problem

On the Average Hourly Distribution chart, the hour labels collapse into an unreadable smear once the window is narrower than roughly 1000px:

00:0001:0002:0003:00… — 24 ticks fighting for space that fits maybe half of them.

The cause is in the x-axis config (dashboard.py, renderHourlyChart):

x: { ticks: { color: C.axis, maxRotation: 0, autoSkip: false, font: { size: 10 } }, ... }

maxRotation: 0 forbids tilting and autoSkip: false forbids dropping ticks, so Chart.js has no escape hatch left — it draws all 24 HH:00 labels at whatever width is available and lets them overlap. On a wide monitor there's enough room that nothing looks wrong, which is presumably why it went unnoticed.

The fix

One line — allow rotation, keep every hour labelled:

x: { ticks: { color: C.axis, minRotation: 0, maxRotation: 90, autoSkip: false, font: { size: 10 } }, ... }

Chart.js now picks the smallest angle that avoids collisions, so nothing changes on wide screens and the labels tilt progressively as the chart narrows. autoSkip: false is kept deliberately: for an hour-of-day axis, hiding every other hour is worse than tilting.

This also brings the chart in line with the Daily Token Usage chart directly above it, which already rotates its date labels — so the two axes no longer disagree about how to handle crowding.

Verification

Headless Chrome against a live dashboard, at two widths:

Viewport Result
900px (where the overlap was reported) labels tilt to ~45°, all 24 readable
560px (narrow panel / mobile) labels tilt further, ~65°, still no overlap
wide unchanged — horizontal, as before

python -m unittest discover -s tests → 147 tests, OK.

Note on the CHANGELOG

The bullet lands under ## v1.5.6 — TBD, which #161 also opens. If #161 merges first this will conflict on that heading — trivial to resolve, and happy to rebase on request.

…overlapping

The Average Hourly Distribution x axis was configured with `maxRotation: 0`
and `autoSkip: false`, which left Chart.js no way to fit 24 `HH:00` ticks into
a narrow chart: it could neither tilt the labels nor skip any, so it drew them
overlapping into an unreadable smear. The wider the window the less visible the
problem, which is why it went unnoticed — at ~900px the ticks already collide.

Allow rotation up to 90 degrees (`minRotation: 0`, `maxRotation: 90`). Chart.js
then picks the smallest angle that avoids collisions: horizontal when there is
room, ~45 degrees around 900px, ~65 degrees at 560px — and all 24 hours stay
labelled at every width. This also matches the Daily Token Usage chart above it,
which already rotates its date labels.
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