Skip to content

feat(charts): accessible chart summaries and a Sparkline component (3.0) - #377

Merged
lorant-one merged 13 commits into
feat/3-0-breaking-cleanupfrom
feat/3-0-chart-a11y-sparkline
Oct 31, 2026
Merged

lorant-one merged 13 commits into
feat/3-0-breaking-cleanupfrom
feat/3-0-chart-a11y-sparkline

Conversation

@lorant-one

Copy link
Copy Markdown
Member

Requested by Lorant · project thread

Step 3 of the 3.0 chart plan (plan doc). It is stacked on #367, so this diff shows only this step. Once #367 merges, retarget it to feat/3-0-breaking-cleanup.

What changes

  • Chart summaries: every chart's plot area is now an image (role="img") to screen readers. Its name is a generated summary, for example "Revenue in forints. Web shop and In store, Jan to May. Web shop: highest 1 950 000 Ft in May, lowest 1 240 000 Ft in Jan…". The summary is written with the chart's own valueFormat and locale. A visually hidden data table sits next to the plot. While a chart is loading, empty or in error, the plot is not an image, so its status is read instead.
  • New props on ChartProps: summary replaces the generated text (the title stays in front), and aria-label replaces the whole name.
  • ChartSummary (exported from /data) renders the hidden table. utils/chartSummary.ts writes the summary text.
  • Sparkline: a server-rendered SVG with no recharts behind it. It takes variant (line, area or bar), curve, showLast, min/max, valueKey, valueFormat, locale and aria-label. It is exported from /data and from the root.
  • Impl files: each of the four chart impl files only swaps its plot Row for the internal ChartPlot. The summary is wired in the public wrappers, so the renderer swap in beta.2 keeps it.
  • Docs: a new Sparkline page (stat tile, table cell, bars, curves), an Accessibility section in setup, and CHANGELOG [3.0.0] entries.
  • AI catalog: the size limit is raised from 25,500 to 25,800 bytes. The catalog was at 25,497 before this PR and is now 25,763.

Checks

  • Core typecheck is clean, and core vitest passes: 282 files, 3,953 tests. That includes the new chart-summary.test.tsx (text, hu-HU/HUF, table, roles, overrides, axe) and sparkline.test.tsx (SSR, curves, bars, showLast, sizing, axe).
  • pnpm test:codemod: 450/450. Docs typecheck and check:docs: 0 problems.
  • Screenshots were taken in the docs dev server at 1280 and 390 wide, light and dark.

Known: the two live-streaming LineChart examples update their summary on every tick. Screen readers don't announce that change, but the hidden table re-renders each time.



Generated by Claude Code

claude added 12 commits October 30, 2026 22:30
… horizontal bars (3.0)

Step 1 of the 3.0 chart plan: the props the renderer swap keeps.

- xKey names the x column (guessed before); series take label and format.
- valueFormat (compact, percent, Intl options or a function) and locale
  write the value axis and tooltip; without them charts draw as 2.x did.
  The value axis widens to fit its longest label.
- stack (true or "percent") on LineChart and BarChart; BarChart
  orientation="horizontal", with category labels sized to fit.
- C8: date.onChange becomes date.onRangeChange; the codemod renames it in
  an inline date and reports one built elsewhere.
- CurveType and ValueFormat types; curveType stays as a deprecated alias.
- Fixes: PieChart gradient ids are scoped to each chart; with no series
  the x column is no longer drawn as a series; ticks find their row in a
  map instead of scanning the data.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
check-props lists inherited ChartProps rows on the mixin's table, so a
component page describing xKey, valueFormat or locale is reported.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
The chart props now use CurveType (curveType stays as a deprecated
alias), so the regenerated spec resolves CurveType, not curveType.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
…line up with the title

A top-left legend was inset a fixed 80px, the old 64px axis plus 16, so a
wider value axis (currency) or the category column of horizontal bars put
it over the axis labels. Legend takes the axis width. Horizontal bars'
category names start 20px in, where the title does, in one column.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
A DatePicker with no value showed this month, read from the clock while
rendering. A page prerendered in one month and opened in the next drew a
different month on the server and in the browser, and hydration failed
(React #418). The docs check visits pages 25 hours after the build, so
every PR's Docs build fails from 30 October 23:00 UTC to the end of the
31st.

Without a date, Calendar and the range calendars start on a fixed month,
hidden, and move to this month in an effect.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
Charts: each plot region is role="img", named by the title and a
plain-language summary of the data written in the chart's valueFormat and
locale ("Revenue and Cost, Jan to Dec. Revenue: highest 12,400 in Aug,
lowest 3,100 in Feb."; a pie: "Share by browser: Chrome 62%, ..."). The
data sits next to it, inside the card, as a visually hidden table (x values
as rows, a column per series label). `summary` replaces the generated text,
`aria-label` the whole name. While a chart loads, fails or is empty the
plot is no image, so its status is read.

The public shells (LineChart.tsx etc.) provide the description context from
their props; a renderer only hands its plot the rows it draws through
`<ChartPlot data={filteredData}>`, so the *.impl.tsx files change by an
import and the plot Row's opening and closing tag.

- utils/chartSummary.ts: chartSummary() and chartSummaryTable()
- ChartSummary: the hidden table, exported from /data
- Sparkline: pure-SVG trend line, area or bars (no recharts, renders on
  the server), viewBox stretched with preserveAspectRatio="none" and a
  non-scaling stroke; data as numbers or rows with valueKey, curve
  (linear, natural, monotone, step), showLast, min/max, width/height
  (a number is px), and a generated aria-label ("Trend from 120 to 340,
  high 360"). Exported from /data and the root barrel.
- Catalog seed entries for both; catalog size budget 25,500 -> 25,800.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
- data/sparkline.mdx: usage, stat tile, table cell (a client example,
  since a Table cell is a function), bars, curves and range, rows with
  valueKey, accessibility and the PropsTable; listed in the Data-viz nav.
- setup.mdx: the Accessibility section and the summary / aria-label rows.
- CHANGELOG [3.0.0] Added: chart summaries and Sparkline.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
…rates

The chart's hidden summary table now writes the rows out on the server, and
the example seeded them with Math.random, so the server and browser differed
(React #418 on /data/lineChart).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
@lorant-one
lorant-one changed the base branch from feat/3-0-chart-props to feat/3-0-breaking-cleanup October 30, 2026 23:51
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq

# Conflicts:
#	CHANGELOG.md
#	packages/core/src/modules/data/interfaces.ts
@lorant-one
lorant-one merged commit c5e4345 into feat/3-0-breaking-cleanup Oct 31, 2026
8 checks passed
lorant-one pushed a commit that referenced this pull request Oct 31, 2026
#377's summaries meet the renderer here. The impl files keep the renderer
and hand their plot to ChartPlot; the wrappers wrap the impl in ChartA11y
directly, with no lazy import left to suspend.

The plot is now role="figure", not "img": the renderer put the legend's
toggle buttons and the keyboard-focusable plot inside it, and an image's
children are presentational (axe nested-interactive). The tests read the
drawn text apart from the hidden summary table, and render with the
LayoutProvider the tooltip needs now the SVG is in the first render.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_016gNJtyZsWugGJ282wnC6vq
@lorant-one
lorant-one deleted the feat/3-0-chart-a11y-sparkline branch October 31, 2026 21:34
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.

2 participants