Skip to content

feat(a11y): provide text alternatives for interactive charts (#777) - #790

Merged
Nanle-code merged 1 commit into
Nanle-code:masterfrom
Jenks00:a11y/chart-text-alternatives-777
Jul 29, 2026
Merged

feat(a11y): provide text alternatives for interactive charts (#777)#790
Nanle-code merged 1 commit into
Nanle-code:masterfrom
Jenks00:a11y/chart-text-alternatives-777

Conversation

@Jenks00

@Jenks00 Jenks00 commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Summary

Recharts renders to SVG with no built-in semantics, so screen reader users got nothing from any chart and keyboard-only users had no way to reach the underlying data. This adds a reusable pattern that exposes both a text summary and a full data table alongside every chart it's applied to.

  • src/utils/chartAccessibility.ts — dependency-free helpers: isRenderableChartData, summarizeSeries (min/max/average/trend), describeChart (one-sentence summary), buildChartTable (headers/rows for an HTML table). All treat null/non-array/empty/non-numeric input as a normal case, not an error.
  • src/components/charts/AccessibleChart.tsx — wrapper component that:
    • renders a visually-hidden summary wired to the chart via aria-describedby, plus aria-label on the chart region
    • renders a keyboard-operable "Show data table" button (aria-expanded) that reveals an accessible <table> with scope="col"/scope="row" headers
    • renders a role="status" message instead of the chart when data is missing, empty, or the wrong shape, instead of handing Recharts something it can't render
  • Adopted in AnalyticsChart.jsx, NetworkStats.tsx, and TransactionAnalyticsDashboard.tsx as the reference implementation — the underlying Recharts trees are unchanged, only wrapped.
  • CHART_ACCESSIBILITY_GUIDE.md documents the pattern, compatibility notes, and a migration checklist for the ~25 remaining Recharts usages across the dashboard.

Test plan

  • npx vitest run src/utils/__tests__/chartAccessibility.test.ts src/components/charts/__tests__/AccessibleChart.test.tsx — 18 tests covering primary flow, boundary cases (single data point, empty dataset), and failure cases (non-array/null/non-numeric data) for both the utilities and the component
  • npx tsc --noEmit — no new type errors
  • npx eslint on all changed files — no new lint errors (only pre-existing warnings in files this PR touches)
  • Manual screen reader spot-check on the three adopted charts (recommended before merge)

Closes #777

…ode#777)

Add a reusable AccessibleChart wrapper and chartAccessibility utilities
that expose a screen-reader summary and a keyboard-toggleable data table
alongside Recharts visualizations, with graceful fallbacks for missing
or malformed chart data. Adopted in AnalyticsChart, NetworkStats, and
TransactionAnalyticsDashboard as the reference implementation, with a
guide for migrating the remaining chart components.
@vercel

vercel Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Jenks00 is attempting to deploy a commit to the nanle-code's projects Team on Vercel.

A member of the Team first needs to authorize it.

@drips-wave

drips-wave Bot commented Jul 29, 2026

Copy link
Copy Markdown

@Jenks00 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Nanle-code
Nanle-code merged commit c9d87e2 into Nanle-code:master Jul 29, 2026
1 check failed
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.

[2026 Accessibility] Provide text alternatives for interactive charts

2 participants