Thinking accessibility while choosing charting libraries

Frontend Developer at Thoughtworks
Search for a command to run...

Frontend Developer at Thoughtworks
No comments yet. Be the first to comment.
Recently, I had the chance to work on SEO (Search Engine Optimization) for one of the projects. I learned a few things along the way. You can follow these steps: Google doesn’t accept any payment to make any website rank better, it all depends on the...

Micro interactions are common on most websites and mobile apps these days to enhance the user experience. I tried creating a simple micro interaction for my portfolio web app. While this could be done with CSS alone, but it is really complex. I found...

Story Behind the Blog Until recently, we managed all our form data using MobX. However, after introducing React Hook Form, form validation became much simpler. We realized that there was no need to save the form data in multiple places since React Ho...

Let's go through the steps to migrate your frontend repo to Vite

build times are high? Give Vite a try

While choosing a charting library we can think of the following parameters to improve the overall accessibility -
Colour contrast ratio
Arial labels / Title / Label/ Description
Simpler charts or tables
Providing text summary of complex charts
Ease of interacting with data elements
Prefer prefers-reduced-motion css media feature
Responsive design
Contrast ratio is a term that’s used to measure the difference between the maximum and minimum brightness of a display. In simple terms the better the ratio the easier it is to differentiate those colours.
Depending on the accessibility level you can choose contrasting colours for the chart elements. There are several tools available to check the CCR ratio.
for e.g. https://contrast-ratio.com
Prefer adding meaningful Arial tags/title/labels/description to the elements which is necessary to be read by the screen reader. you can check if the elements are being correctly read by using the following screen readers - JAWS, Voice Over(IOS), NVDA
There will be scenarios where you might have to choose between charts. In such situations always prefer simpler charts with fewer UI elements. for simpler datasets preferably go for data tables.
If it is extremely necessary to have a complex chart then in such scenarios always provide a gist of the value provided by the chart either as a label or description. Nowadays most charting libraries allow developers to add labels and descriptions to the data elements as well.
For example, in chart.js you can provide arial-label, and role.
<canvas id="goodCanvas1" width="400" height="100" aria-label="Hello ARIA World" role="img"></canvas>
In a web application, the ease of navigating through the UI elements using the keyboard is quite an important factor for accessibility. Similarly in charts, the user should be able to navigate through the chart elements using the keyboard.
To understand this better let's check the type of charting libraries available -
SVG-based - creates DOM elements for charts which are focusable by keyboard with modification like adding tab-index. Although adding tab-index at runtime is difficult and tedious. so preferably go for a library like Highcharts or amCharts which has out-of-the-box support to add focusable elements.
Canvas-based - uses Canvas API to draw chart elements. so keyboard navigation will be difficult but there are a few libraries like amChart version 5 which allow keyboard navigation to predefined focusable elements.
The prefers-reduced-motion CSS media feature is used to detect if the user has requested that the system minimize the amount of non-essential motion it uses.
Animations on charts may be a distraction for some specially-abled users, so it's always good to use this media feature to remove or reduce the animations on charts.

Keeping the charts responsive will help the user gain the same value on any device. Most libraries these days support responsive design.
Following are the few popular charting libraries available which have good to basic support for accessibility -
SVG-based, Paid, Good accessibility support is available
version 4- SVG based, Paid, Good accessibility support available
version 5 - Canvas based, Paid, Good accessibility support available
Canvas-based, free, Very Basic accessibility support is available
SVG based, free, No out of the box support for accessibility but possible to improve by adding labels and having a good CCR ratio. click this to know more.
Feel free to comment if any feedback or concerns. Thanks !