Skip to content

fix: Bubble charts a11y issue#199

Merged
georgylobko merged 1 commit intomainfrom
fix/bubble-chart-a11y
Apr 7, 2026
Merged

fix: Bubble charts a11y issue#199
georgylobko merged 1 commit intomainfrom
fix/bubble-chart-a11y

Conversation

@georgylobko
Copy link
Copy Markdown
Member

Description

AWSUI-61878
Added ARIA label attribute for the cartesian bubble chart

Related links, issue #, if available: n/a

How has this been tested?

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@georgylobko georgylobko force-pushed the fix/bubble-chart-a11y branch from 60ce043 to 6c0f9fa Compare April 2, 2026 10:03
@georgylobko georgylobko marked this pull request as ready for review April 2, 2026 10:26
@georgylobko georgylobko requested a review from a team as a code owner April 2, 2026 10:26
@georgylobko georgylobko requested review from avinashbot and pan-kot and removed request for a team April 2, 2026 10:26
Comment thread src/core/chart-core.tsx Outdated
// Point description formatter is overridden to respect custom axes value formatters.
descriptionFormatter: (point) => getPointAccessibleDescription(point, labels),
descriptionFormatter: (point) =>
getPointAccessibleDescription(point, labels, { sizeAxis: rest.sizeAxis as CoreChartProps.SizeAxisOptions[] }),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why is typecast needed here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Because we are casting to readonly type here. Made it slightly differently to align with a similar code for the tooltip

Comment thread src/core/utils.ts Outdated
if (point.series.type === "bubble") {
const matchedSizeAxis =
additionalProps?.sizeAxis?.find((a) => a.id === getBubbleSeriesSizeAxis(point.series)) ??
additionalProps?.sizeAxis?.[0];
Copy link
Copy Markdown
Member

@pan-kot pan-kot Apr 7, 2026

Choose a reason for hiding this comment

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

The same code is used in the tooltip - should we make a matchSizeAxis() helper?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Sounds good. Addressed

Comment thread src/core/utils.ts
if (additionalProps?.sizeAxis && point.series.type === "bubble") {
const matchedSizeAxis = matchSizeAxis(additionalProps.sizeAxis, point.series);
const size = point.options.z ?? null;
const sizeFormatter = getFormatter(matchedSizeAxis);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit: would it make sense to make size and formatter extraction in the util?

export function getMatchedSizeAxisProps(sizeAxis, point) {
  const series = point.series;
  const matched = sizeAxis?.find((a) => a.id === getBubbleSeriesSizeAxis(series)) ?? sizeAxis?.[0];
  if (!matched) {
    return null;
  }
  return { size: point.options.z ?? null, formatter: getFormatter(matched) };
}

Copy link
Copy Markdown
Member

@pan-kot pan-kot Apr 7, 2026

Choose a reason for hiding this comment

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

or maybe just return the formatted size?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

export function getFormattedSize(sizeAxis, point) {
  const series = point.series;
  const matched = sizeAxis?.find((a) => a.id === getBubbleSeriesSizeAxis(series)) ?? sizeAxis?.[0];
  if (!matched) {
    return null;
  }
  const size = point.options.z ?? null;
  const formatter = getFormatter(matched);
  return formatter(size);
}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'd say we would barely benefit from it, because we need the matchedSizeAxis title in the tooltip, while we don't need it in the getPointAccessibleDescription, so I would keep it as is for now. No strong opinion here, but if we need to reuse or extend it at some point in future, we can always do this

Comment thread src/core/utils.ts Outdated

export function getPointAccessibleDescription(point: Highcharts.Point, labels: ChartLabels) {
export function matchSizeAxis(sizeAxis: readonly CoreChartProps.SizeAxisOptions[], series: Highcharts.Series) {
return sizeAxis?.find((a) => a.id === getBubbleSeriesSizeAxis(series)) ?? sizeAxis?.[0];
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

sizeAxis is not optional as its argument type suggests, so no need to use optional chaining here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

addressed

@georgylobko georgylobko added this pull request to the merge queue Apr 7, 2026
Merged via the queue into main with commit c819b7f Apr 7, 2026
44 checks passed
@georgylobko georgylobko deleted the fix/bubble-chart-a11y branch April 7, 2026 15:38
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