feat(a11y): provide text alternatives for interactive charts (#777) - #790
Merged
Nanle-code merged 1 commit intoJul 29, 2026
Merged
Conversation
…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.
|
@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. |
|
@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! 🚀 |
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.
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 treatnull/non-array/empty/non-numeric input as a normal case, not an error.src/components/charts/AccessibleChart.tsx— wrapper component that:aria-describedby, plusaria-labelon the chart regionaria-expanded) that reveals an accessible<table>withscope="col"/scope="row"headersrole="status"message instead of the chart when data is missing, empty, or the wrong shape, instead of handing Recharts something it can't renderAnalyticsChart.jsx,NetworkStats.tsx, andTransactionAnalyticsDashboard.tsxas the reference implementation — the underlying Recharts trees are unchanged, only wrapped.CHART_ACCESSIBILITY_GUIDE.mddocuments 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 componentnpx tsc --noEmit— no new type errorsnpx eslinton all changed files — no new lint errors (only pre-existing warnings in files this PR touches)Closes #777