fix(dashboard): let the hourly chart's hour labels rotate instead of overlapping - #172
Open
DiegoDAF wants to merge 1 commit into
Open
fix(dashboard): let the hourly chart's hour labels rotate instead of overlapping#172DiegoDAF wants to merge 1 commit into
DiegoDAF wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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):maxRotation: 0forbids tilting andautoSkip: falseforbids dropping ticks, so Chart.js has no escape hatch left — it draws all 24HH:00labels 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:
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: falseis 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:
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.