Skip to content

fix: horizontal autoSkip ticks on line/area chart X axis - #310

Merged
BorisTyshkevich merged 1 commit into
mainfrom
fix/chart-line-xaxis-ticks
Jul 18, 2026
Merged

fix: horizontal autoSkip ticks on line/area chart X axis#310
BorisTyshkevich merged 1 commit into
mainfrom
fix/chart-line-xaxis-ticks

Conversation

@BorisTyshkevich

Copy link
Copy Markdown
Collaborator

Summary

  • Line/area charts still draw a Chart.js category scale (one tick per row — no time scale yet), so at a few hundred rows the default rotation (up to 50°) produced an unreadable wall of rotated timestamp labels.
  • chartJsConfig (src/core/chart-data.ts) now sets autoSkip: true, maxRotation: 0, minRotation: 0 on the category (X) axis ticks for line/area charts only, so Chart.js drops enough labels to stay horizontal. Bar/hbar/pie category axes are unchanged.
  • Added tests/unit/chart-data.test.ts coverage asserting the new tick options on line/area and their absence on bar/hbar.
  • CHANGELOG [Unreleased] entry added, cross-linking the follow-up.

Filed #309 as a follow-up: a genuine Chart.js time scale (natural tick boundaries, gap-aware point placement) for time-role X columns, since a category scale still evenly spaces irregularly-sampled timestamps even with this fix.

Test plan

  • npm test — 145 test files / 3560 tests pass, 100% line/statement/function coverage on chart-data.ts maintained (branches 97.51%, above the 90% floor)
  • npm run check:types (tsc --noEmit) passes
  • npm run build succeeds

🤖 Generated with Claude Code

https://claude.ai/code/session_01Mf8cy6d2qWcbvuSzvtf7m4

…follow-up)

Line/area charts draw a Chart.js category scale with one tick per row; at a
few hundred rows the default up-to-50° rotation was an unreadable wall of
timestamps. Force maxRotation/minRotation:0 + autoSkip so Chart.js drops
enough labels to stay horizontal instead. Bar/hbar/pie unaffected.

A genuine Chart.js time scale (natural tick boundaries, gap-aware placement)
is filed as a follow-up: #309.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Mf8cy6d2qWcbvuSzvtf7m4
@BorisTyshkevich
BorisTyshkevich merged commit 1eeb471 into main Jul 18, 2026
9 checks passed
BorisTyshkevich added a commit that referenced this pull request Jul 19, 2026
…time-role X (#312)

* feat(#309): Chart.js time scale for line/area charts over a time-role X

Line/area charts whose X column is time-role (`chartRole` = 'time') now draw
a genuine Chart.js `scales.x.type: 'time'` instead of the category scale:
ticks land on natural time boundaries and points sit at their real elapsed
time, so gaps in irregularly-sampled data show as gaps instead of being
compressed away. A new pure `chartTimeValue()` parses ClickHouse
Date/DateTime/DateTime64 strings into epoch-ms (literal wall-clock digits, no
timezone conversion, with a calendar round-trip check so an invalid-but-
date-shaped value falls back rather than silently rolling over); any
unparseable displayed category falls the whole axis back to the existing
category scale. Bar/hbar/pie and non-time-role line/area charts are
unaffected.

Fifth bundled runtime dependency (CLAUDE.md rule 4): chartjs-adapter-date-fns
(+ its date-fns peer), imported as a side-effect registration in main.ts next
to chart.js/auto. Measured +11.6 KiB gzip / +9.7 KiB brotli.

Fixes a tooltip regression the time-scale change would otherwise introduce:
under the time scale, Chart.js's tooltip `context.raw` is the dataset's own
`{x,y}` point object rather than a bare number, so an authored value format
now extracts `.y` before formatting instead of formatting the point object
itself (which would render every tooltip as "—").

Follow-up to #310 (the category-axis autoSkip mitigation). Filed #311 (inbox)
for a narrower, out-of-scope DST-transition edge case in the new local
wall-clock time parsing.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GLMprUnwnz4oaz3cnLRKcz

* feat(#309): extend the time scale to bar and hbar charts

Per user follow-up feedback on the served PR build: the same real Chart.js
time scale now applies to vertical bar/column and horizontal bar (hbar), not
just line/area. hbar's category axis is Y (indexAxis:'y'), so its time-scale
points carry the epoch in `y` and the value in `x` — the mirror of every
other cartesian type. Pie stays excluded (no axis).

Also tightens the defensive fallback: an empty result (zero displayed
categories) no longer vacuously satisfies "every category parsed" and
claims a time axis with nothing to plot.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GLMprUnwnz4oaz3cnLRKcz

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
@BorisTyshkevich
BorisTyshkevich deleted the fix/chart-line-xaxis-ticks branch August 6, 2026 15:28
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