fix: Bubble charts a11y issue#199
Conversation
60ce043 to
6c0f9fa
Compare
| // 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[] }), |
There was a problem hiding this comment.
Because we are casting to readonly type here. Made it slightly differently to align with a similar code for the tooltip
| if (point.series.type === "bubble") { | ||
| const matchedSizeAxis = | ||
| additionalProps?.sizeAxis?.find((a) => a.id === getBubbleSeriesSizeAxis(point.series)) ?? | ||
| additionalProps?.sizeAxis?.[0]; |
There was a problem hiding this comment.
The same code is used in the tooltip - should we make a matchSizeAxis() helper?
There was a problem hiding this comment.
Sounds good. Addressed
| if (additionalProps?.sizeAxis && point.series.type === "bubble") { | ||
| const matchedSizeAxis = matchSizeAxis(additionalProps.sizeAxis, point.series); | ||
| const size = point.options.z ?? null; | ||
| const sizeFormatter = getFormatter(matchedSizeAxis); |
There was a problem hiding this comment.
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) };
}
There was a problem hiding this comment.
or maybe just return the formatted size?
There was a problem hiding this comment.
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);
}
There was a problem hiding this comment.
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
|
|
||
| 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]; |
There was a problem hiding this comment.
sizeAxis is not optional as its argument type suggests, so no need to use optional chaining here
fda28af to
48e4fc0
Compare
Description
AWSUI-61878Added 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
CONTRIBUTING.md.CONTRIBUTING.md.Security
checkSafeUrlfunction.Testing
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.