Skip to content

fix(charts): descriptive aria labels for all chart types (a11y) - #1108

Merged
alfredo1996 merged 2 commits into
release/1.1from
design/chart-aria-labels
Jun 20, 2026
Merged

fix(charts): descriptive aria labels for all chart types (a11y)#1108
alfredo1996 merged 2 commits into
release/1.1from
design/chart-aria-labels

Conversation

@alfredo1996

@alfredo1996 alfredo1996 commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

General-quality (not branding) finding from the per-chart review: 9 charts had no screen-reader description. They never set ariaDescription, so BaseChart fell back to the generic aria-label="Chart visualization". (bar/line/graph already derived one.)

Each now derives a description from its data shape, with callers still able to override:

Chart aria-label (before → after)
pie Chart visualizationPie chart with 5 segments
radar Chart visualizationRadar chart comparing 2 series across 5 axes
gauge Chart visualizationGauge showing 75 of 0 to 100
sankey Chart visualizationSankey diagram with 8 nodes and 12 links
treemap Chart visualizationTreemap with 6 top-level items
sunburst Chart visualizationSunburst chart with 4 top-level segments
circle-packing Chart visualizationCircle-packing chart with 4 top-level groups
gantt Chart visualizationGantt chart with 8 tasks
choropleth Chart visualizationChoropleth map with 50 regions

(No visual change — this is an accessibility-tree improvement, so before/after is the aria-label text above.)

Tests

  • New parametrized chart-aria.test.tsx asserts each chart's descriptive label + the caller-override path. tsc · 561 chart tests · lint clean.

Summary by CodeRabbit

Release Notes

  • New Features

    • Chart components now support custom accessibility descriptions via a configurable option
    • Automatic fallback descriptions generated based on chart type and data content
    • Enhanced screen reader support across all chart types
  • Tests

    • Added comprehensive test coverage for chart accessibility labels

General-quality review finding (not branding): pie, radar, gauge, sankey,
treemap, sunburst, circle-packing, gantt and choropleth never computed an
ariaDescription, so BaseChart fell back to the generic "Chart visualization"
for screen readers (bar/line/graph already do this). Each now derives a
description from its data shape (e.g. "Pie chart with 5 segments", "Sankey
diagram with 8 nodes and 12 links"), with the caller still able to override.

New parametrized chart-aria test covers every chart + the override path.
tsc + 561 chart tests + lint clean.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@alfredo1996 alfredo1996 added area:a11y Accessibility area:charts Chart rendering pkg:component UI component library labels Jun 20, 2026
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alfredo1996, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 47 minutes and 10 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 674d3541-8fbb-4198-b0e3-422ae9130862

📥 Commits

Reviewing files that changed from the base of the PR and between 4dea3cf and 331b0a5.

📒 Files selected for processing (1)
  • component/src/charts/__tests__/chart-aria.test.tsx

Walkthrough

Nine chart components (pie, radar, gauge, sankey, treemap, sunburst, circle-packing, gantt, choropleth) now accept an ariaDescription prop and forward it to BaseChart, falling back to a data-derived default string when omitted. A new test file validates the rendered aria-label for each chart type and the override behavior.

Changes

Chart ariaDescription wiring and tests

Layer / File(s) Summary
ariaDescription prop destructuring and BaseChart forwarding
component/src/charts/pie-chart.tsx, component/src/charts/radar-chart.tsx, component/src/charts/gauge-chart.tsx, component/src/charts/sankey-chart.tsx, component/src/charts/treemap-chart.tsx, component/src/charts/sunburst-chart.tsx, component/src/charts/circle-packing-chart.tsx, component/src/charts/gantt-chart.tsx, component/src/charts/choropleth-chart.tsx
Each component destructures ariaDescription from its props and passes it to BaseChart, computing a chart-type-specific fallback string from data dimensions when the prop is absent.
Aria-label test suite
component/src/charts/__tests__/chart-aria.test.tsx
Mocks echarts/core and useContainerSize, then runs a parameterized test over all nine chart types asserting base-chart aria-label matches per-chart regexes, plus a separate test that the ariaDescription prop overrides the computed value.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • alfredo1996/neoboard#870: Modifies the same ariaDescription/ARIA label plumbing in BaseChart and related chart components (bar/line), sharing the same pattern of forwarding computed accessibility descriptions.

Suggested labels

bug

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: adding descriptive ARIA labels to chart types for accessibility improvements.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch design/chart-aria-labels

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@component/src/charts/circle-packing-chart.tsx`:
- Around line 272-275: The ariaDescription fallback at the Circle-packing chart
component is using data.length to count top-level groups, but this is incorrect
for hierarchical input where a single root node contains multiple child groups.
Instead of using data.length directly in the aria description, check if the
first element in data has children (indicating a hierarchical structure), and if
so, count the children of that root node; otherwise, use data.length as the
fallback. This ensures the aria label accurately reflects the actual number of
top-level groups visible in the chart regardless of whether the input is flat or
hierarchical.

In `@component/src/charts/pie-chart.tsx`:
- Around line 193-195: The ariaDescription fallback template in the pie chart
component is using data.length to report the segment count, but when topN
grouping is applied, the actual rendered number of segments may be different
from the raw data length. Replace data.length in the ariaDescription with the
length of the actual rendered/processed data that accounts for the topN
parameter to ensure screen readers announce the correct number of segments that
are actually displayed in the pie chart.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 6f0493a8-e915-4512-84d0-5b546019f494

📥 Commits

Reviewing files that changed from the base of the PR and between c4d138b and 4dea3cf.

📒 Files selected for processing (10)
  • component/src/charts/__tests__/chart-aria.test.tsx
  • component/src/charts/choropleth-chart.tsx
  • component/src/charts/circle-packing-chart.tsx
  • component/src/charts/gantt-chart.tsx
  • component/src/charts/gauge-chart.tsx
  • component/src/charts/pie-chart.tsx
  • component/src/charts/radar-chart.tsx
  • component/src/charts/sankey-chart.tsx
  • component/src/charts/sunburst-chart.tsx
  • component/src/charts/treemap-chart.tsx

Comment on lines +272 to +275
ariaDescription={
ariaDescription ??
`Circle-packing chart with ${data.length} top-level groups`
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Fallback group count can be wrong for single-root hierarchical input.

At Line 272, data.length reports 1 when input is a single root node with many children, so the aria label undercounts top-level groups.

Proposed fix
+  const topLevelGroupCount =
+    data.length === 1 && data[0]?.children?.length
+      ? data[0].children.length
+      : data.length;
+
   return (
     <div ref={containerRef} className="h-full w-full">
       <BaseChart
         options={options}
         ariaDescription={
           ariaDescription ??
-          `Circle-packing chart with ${data.length} top-level groups`
+          `Circle-packing chart with ${topLevelGroupCount} top-level groups`
         }
         {...rest}
       />
     </div>
   );
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ariaDescription={
ariaDescription ??
`Circle-packing chart with ${data.length} top-level groups`
}
const topLevelGroupCount =
data.length === 1 && data[0]?.children?.length
? data[0].children.length
: data.length;
return (
<div ref={containerRef} className="h-full w-full">
<BaseChart
options={options}
ariaDescription={
ariaDescription ??
`Circle-packing chart with ${topLevelGroupCount} top-level groups`
}
{...rest}
/>
</div>
);
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@component/src/charts/circle-packing-chart.tsx` around lines 272 - 275, The
ariaDescription fallback at the Circle-packing chart component is using
data.length to count top-level groups, but this is incorrect for hierarchical
input where a single root node contains multiple child groups. Instead of using
data.length directly in the aria description, check if the first element in data
has children (indicating a hierarchical structure), and if so, count the
children of that root node; otherwise, use data.length as the fallback. This
ensures the aria label accurately reflects the actual number of top-level groups
visible in the chart regardless of whether the input is flat or hierarchical.

Comment on lines +193 to +195
ariaDescription={
ariaDescription ?? `Pie chart with ${data.length} segments`
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Use rendered segment count in the fallback aria description.

Line 194 uses data.length, but the rendered pie can be grouped by topN, so screen readers may get an incorrect segment count.

Suggested fix
-        ariaDescription={
-          ariaDescription ?? `Pie chart with ${data.length} segments`
-        }
+        ariaDescription={
+          ariaDescription ??
+          `Pie chart with ${topN > 0 && data.length > topN ? topN + 1 : data.length} segments`
+        }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ariaDescription={
ariaDescription ?? `Pie chart with ${data.length} segments`
}
ariaDescription={
ariaDescription ??
`Pie chart with ${topN > 0 && data.length > topN ? topN + 1 : data.length} segments`
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@component/src/charts/pie-chart.tsx` around lines 193 - 195, The
ariaDescription fallback template in the pie chart component is using
data.length to report the segment count, but when topN grouping is applied, the
actual rendered number of segments may be different from the raw data length.
Replace data.length in the ariaDescription with the length of the actual
rendered/processed data that accounts for the topN parameter to ensure screen
readers announce the correct number of segments that are actually displayed in
the pie chart.

GanttDataItem is { task: string; start: number; end: number } — the aria test
used name/string dates. CI's full tsc (includes tests) caught it.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@alfredo1996
alfredo1996 merged commit d0e312c into release/1.1 Jun 20, 2026
15 checks passed
@alfredo1996
alfredo1996 deleted the design/chart-aria-labels branch June 20, 2026 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:a11y Accessibility area:charts Chart rendering pkg:component UI component library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants