Skip to content

Charts: lighter scatter plots, compressed pages and keyboard access (#76, #32) - #115

Merged
Luen merged 1 commit into
mainfrom
charts-perf-a11y
Nov 3, 2026
Merged

Luen merged 1 commit into
mainfrom
charts-perf-a11y

Conversation

@Luen

@Luen Luen commented Nov 3, 2026

Copy link
Copy Markdown
Collaborator

Closes #76. Closes #32. These were the last two open items in the design and charts epic (#70).

#76: page weight

On the real data, most of the weight was SVG markup rather than data. /morphometrics, for example, was 829 KB, of which 626 KB was about 2,500 per-point <circle>s with their wrapper groups and hydration comments.

  • Scatter:
    • Big charts: above 250 points the server sends one <path> of round-capped dots per colour (a few bytes a point). The real circles, with their see-through overlaps, replace it once the page is interactive.
    • Leaner markup: colour, opacity and outline now sit on one <g> per colour, and coordinates are rounded to 0.1 px.
    • Hover: one handler picks the nearest point, so small dots are easier to hit.
  • Compression (hooks.server.ts): adapter-node only precompresses static files, so rendered HTML and JSON now go out with Brotli or gzip.
  • ETag: pages get a weak ETag built from the build version and the import hash, with Cache-Control: no-cache, so a browser revalidating an unchanged page gets a 304 without a render. /health is left alone.
  • /sharks: stops sending fields the page can derive or never shows (the link, the tagged flag, conflict).

Measured on the real workbooks (dev server):

Page Before After (uncompressed) After (transferred, Brotli)
/morphometrics 829 KB 224 KB 41 KB
/neonates 824 KB 244 KB 41 KB
/growth 646 KB 234 KB 40 KB
/sharks 628 KB 488 KB 45 KB
/time-of-day 426 KB 148 KB ~30 KB

Every page now transfers under 50 KB, against the issue's target of about 300 KB. Uncompressed, /sharks and /notes are still above 300 KB, because both send the whole list for client-side search. Paginating them on the server is possible if that ever matters.

#32: keyboard access and reduced motion

  • Shared helper: new charts/marks.ts. markKeys() makes each chart a single tab stop that steps through its marks:
    • left/right arrows move between marks, and up/down move between rows on heatmaps;
    • Home/End jump to the first or last mark;
    • Enter follows a mark's link, and Escape hides the tooltip.
  • Announcements: the tooltip already has role="status", so each value is read out. While a chart has marks its svg is role="application", so screen readers pass the arrow keys through instead of browsing. A chart with nothing to read stays an unfocusable img.
  • All nine chart types (Bar, Line, Histogram, BoxPlot, Heatmap, Polar, Timeline, ForestPlot, Scatter) use the helper. Each mark carries data-mark, and the keyboard tooltip is pinned at that mark's centre. Linked scatter points are now <a aria-label>.
  • Reduced motion: a global prefers-reduced-motion override for animations, transitions and smooth scrolling, and no Leaflet zoom or fade animation.
  • AGENTS.md explains how a new chart should hook in.

Checks

  • pnpm lint, pnpm check, pnpm test (75 passed)
  • pnpm build && pnpm test:e2e: 31 passed. New tests:
    • keyboard reading of every chart on /morphometrics;
    • compressed responses, an ETag, and a 304 on revalidation;
    • axe in light and dark now also covers /morphometrics and /pressure.
  • In the browser, on the real data: arrow keys bring up a tooltip on every chart on /tides, /time-of-day, /drivers and /physiology. The only exceptions are two box plots that have no data at all. Hover on a 2,115-point scatter also works.

🤖 Generated with Claude Code

, #32)

#76 page weight:
- Scatter sends one path of dots per colour above 250 points and draws the
  circles after mount; hover picks the nearest point; coordinates rounded to
  0.1 px and shared attributes moved onto one group per colour.
- hooks.server.ts compresses HTML and JSON (Brotli/gzip) and sets a weak ETag
  from the build version and import hash, answering revalidation with a 304.
- /sharks no longer ships derivable fields.

#32 keyboard and motion:
- charts/marks.ts: markKeys (one tab stop per chart, arrows/Home/End step
  through marks, Enter follows links, Escape hides) and markAt/pointerIn.
  All nine chart types use it; tooltips announce via role="status".
- Reduced motion: global CSS override and no Leaflet zoom/fade animation.
- e2e: keyboard test, compression/304 test, axe on /morphometrics and /pressure.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Luen Luen added accessibility Barrier affecting people with disabilities enhancement New feature or request design Visual design, theme and charts labels Nov 3, 2026
@Luen Luen mentioned this pull request Nov 3, 2026
@Luen
Luen merged commit 4477fbc into main Nov 3, 2026
5 checks passed
@Luen
Luen deleted the charts-perf-a11y branch November 3, 2026 22:25
@Luen Luen mentioned this pull request Nov 3, 2026
9 tasks done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

accessibility Barrier affecting people with disabilities design Visual design, theme and charts enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Performance: large page payloads on scatter-heavy pages Accessibility: axe in CI, keyboard tooltips, colour-blind safe palette

1 participant