Skip to content

Commit 0e651eb

Browse files
committed
docs(data-a11y): a11y fixes
1 parent 9f6bb82 commit 0e651eb

File tree

3 files changed

+52
-4
lines changed

3 files changed

+52
-4
lines changed

packages/paste-libraries/data-visualization/src/transformers/baseFormatter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,10 @@ export const handleBaseChartOptionsFormatting = ({
2525
const context = React.useContext(ThemeContext) as ThemeShape;
2626

2727
return {
28-
accessibility,
28+
accessibility: {
29+
enabled: true,
30+
...accessibility,
31+
},
2932
chart: {
3033
resetZoomButton: {
3134
theme: {

packages/paste-website/src/component-examples/data-visualization/ChartExamples.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -390,3 +390,37 @@ const SimpleChartAccessibilityExample = () => {
390390
391391
render(<SimpleChartAccessibilityExample />);
392392
`.trim();
393+
394+
export const SimpleChartAccessibilityDefaultExample = `
395+
const SimpleChartAccessibilityDefaultExample = () => {
396+
const lineSeriesData = [
397+
{
398+
name: "Installation",
399+
data: [43934, 52503, 57177, 69658, 97031, 119931, 137133, 154175],
400+
},
401+
{
402+
name: "Manufacturing",
403+
data: [24916, 24064, 29742, 29851, 32490, 30282, 38121, 40434],
404+
},
405+
]
406+
407+
return (
408+
<ChartProvider options={{
409+
type: "line",
410+
series: lineSeriesData,
411+
title: {
412+
text: "Solar Employment Growth by Sector, 2010-2016",
413+
hide: true,
414+
},
415+
subtitle: {
416+
text: "Source: thesolarfoundation.com",
417+
hide: true,
418+
}
419+
}}>
420+
<BaseChart />
421+
</ChartProvider>
422+
);
423+
};
424+
425+
render(<SimpleChartAccessibilityDefaultExample />);
426+
`.trim();

packages/paste-website/src/pages/foundations/data-visualization/for-engineers/accessibility.mdx

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import { SidebarCategoryRoutes } from "../../../../constants";
2424
import DefaultLayout from "../../../../layouts/DefaultLayout";
2525
import { getNavigationData } from "../../../../utils/api";
2626
import { ExamplesDataVizBaseChart as BaseChart } from "../../../../component-examples/data-visualization/BaseChart";
27-
import { SimpleChartAccessibilityExample } from "../../../../component-examples/data-visualization/ChartExamples";
27+
import { SimpleChartAccessibilityExample, SimpleChartAccessibilityDefaultExample } from "../../../../component-examples/data-visualization/ChartExamples";
2828

2929
export default DefaultLayout;
3030

@@ -58,7 +58,7 @@ export const getStaticProps = async () => {
5858
</Callout>
5959
</Box>
6060

61-
Highcharts offers an accessibility module which we recommend always enabling. If using our [BaseChart](foundations/data-visualization/for-engineers#basechart) implementation, this is taken care of. It provides many useful features that help visually impaired users interact and understand charts. More information on this module can be found on [Highcharts docs](https://www.highcharts.com/docs/accessibility/accessibility-module). Features that are offered are:
61+
Highcharts offers an accessibility module which we recommend always enabling. If using our [BaseChart](/foundations/data-visualization/for-engineers#basechart) implementation, this is taken care of. It provides many useful features that help visually impaired users interact and understand charts. More information on this module can be found on [Highcharts docs](https://www.highcharts.com/docs/accessibility/accessibility-module). Features that are offered are:
6262
- Announces chart metadata such as title, subtitle, and description.
6363
- Allows keyboard navigation of series, points, and legend items.
6464
- Describes series when focused.
@@ -76,10 +76,21 @@ The accessibility module provides announcements by default for the series and po
7676

7777
### Customizing announcements
7878

79-
To override the default announcements you can set the `accessibility` attribute in the support options of the [Chart Provider](components/chart-provider/api#charttypeoptions)
79+
To override the default announcements you can set the `accessibility` attribute in the support options of the [Chart Provider](/components/chart-provider/api#charttypeoptions)
8080

8181
The point and series will be passed to the `descriptionFormatter` to retrieve the correct values, such as axis values and series names.
8282

83+
Below is an example where we have not overriden the default announcements to understand the base features.
84+
85+
<LivePreview
86+
scope={{ChartProvider, BaseChart}}
87+
language="jsx"
88+
noInline
89+
>
90+
{SimpleChartAccessibilityDefaultExample}
91+
</LivePreview>
92+
93+
8394
## Custom example
8495

8596
Below is an example of a chart with custom `descriptionFormatter` for the series and point. The title and sub title are both specified but hidden. They will still be included in the screen reader announcements to give context to visually impaired users but not be visible on the chart.

0 commit comments

Comments
 (0)