Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

a11y: support ARIA attributes, role and fallback content for canvas #1060

Closed
1 task done
d-koppenhagen opened this issue Nov 21, 2023 · 0 comments · Fixed by #1061
Closed
1 task done

a11y: support ARIA attributes, role and fallback content for canvas #1060

d-koppenhagen opened this issue Nov 21, 2023 · 0 comments · Fixed by #1061

Comments

@d-koppenhagen
Copy link
Contributor

Would you like to work on this feature?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

What problem are you trying to solve?

The underlying lib Chart.js renders everything on a canvas. So it's up to us as developers to make charts accessible by providing ARIA attributes / an appropriate role. In the Chart.js docs are some hints about how to make the charts accessible:
https://www.chartjs.org/docs/latest/general/accessibility.html

Currently this wrapper lib creates only a plain canvas element:
https://github.com/apertureless/vue-chartjs/blob/main/src/chart.ts#L115-L117

Describe the solution you'd like

In my opinion there are four things that should be supported by properties / slots and added to the canvas element.

  • role: should be defaulted to img to help e.g. screen readers to interpret the canvas semantic (image of a chart)
  • aria-label: should be supported by a property to describe the image / chart for visually impaired users
  • Fallback-Content: should be supported by a Slot to be able to show when the Browser isn't able to render the canvas
  • aria-describedby should be supported by a property to be able to refer to a describing element (e.g. a table representation of the data)

All the points are currently only be able to implement by accessing the ref of the canvas and modifying it which is quite complicated.

The result could look like this:

<canvas
  id="myChartCanvas"
  width="400"
  height="100"
  aria-label="myAriaLabel" role="img"
  aria-describedby="rawChartDataAsTable">
  Some fallback content displayed, when the canvas could not be rendered.
</canvas>
<table id="rawChartDataAsTable"> ... </table>

Describe alternatives you've considered

Documentation, Adoption, Migration Strategy

This shouldn't be a breaking change.

@d-koppenhagen d-koppenhagen changed the title a11y: provide a11y: support ARIA attributes, role and fallback content for canvas Nov 21, 2023
d-koppenhagen added a commit to d-koppenhagen/vue-chartjs that referenced this issue Nov 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants