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

Added ariaHidden to exampleLineCharts #789

Open
wants to merge 36 commits into
base: exampleLineCharts
Choose a base branch
from

Conversation

halimahLDN
Copy link
Contributor

@halimahLDN halimahLDN commented Jan 16, 2025

What does this change?
Originally
I've added ariaLabel and ariaHidden attributes to the example line chart, to demonstrate how we can incorporate accessibility best practice.

I don't think this is quite perfect due to the following:

  • Adding ariaHidden: 'true' to Plot marks, successfully hides the SVG elements from the screen reader. Except for the axis marks, if they have a label.
  • ariaDescription doesn’t appear to work inside marks or the spec - the screen reader ignores it
  • ariaLabel on the Plot.line() makes the line disappear
  • ariaLabel on the spec (outside of marks) DOES work but the screen reader still reads the y axis label, as it's not hidden
  • The ariaLabel isn't achieving much more than the subTitle is, so we could instead replace it with a slightly more descriptive subTitle and hide the chart (though how to hide the chart remains to be seen, given the above re axis labels)

Now
I've instead added an optional prop ariaHidden to ObservablePlotInner which defaults to true, hiding the chart contents. I've removed the individual ARIA attributes in the exampleLineChart marks and updated the title and subtitle to be more descriptive.

I've since also added ariaDetails and ariaDescribedBy props which default to empty strings. So more detailed descriptions of the chart contents can be shared.

Related issues: #762

Is it complete?

  • Have you included changeset file?

@halimahLDN halimahLDN changed the base branch from main to exampleLineCharts January 16, 2025 10:28
@halimahLDN halimahLDN changed the title Example line charts accessibility Added ariaHidden to exampleLineCharts Jan 16, 2025
@halimahLDN halimahLDN marked this pull request as ready for review January 16, 2025 13:03
@halimahLDN halimahLDN added the Ally An issue affecting accessibility label Jan 16, 2025
@halimahLDN
Copy link
Contributor Author

halimahLDN commented Jan 22, 2025

I've now implemented chartDescription in the example line chart, both as a modal for sighted users and an sr-only description in the ChartContainer.

I've now:

  • added chartDescription as a prop to ObservablePlot, ChartContainer and Footer
  • added ariaDescribedBy id to ObservablePlotInner and chartDescription in ChartContainer
  • added id, ariaHidden and ariaDescribedBy props to ObservablePlotInner
  • corrected spelling of 'Default' in DefaultPlotStyleFunctions
  • exported randomId from @ldn-viz/ui for use in charts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Ally An issue affecting accessibility
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant