Skip to content
easeweb
Search topics

Chart tooltips a keyboard can't open

A bar chart's counts appear only in the tooltip Chart.js draws while the pointer is on a bar, and the canvas never takes focus, so no key brings one up.

WCAG 2.2
SC 2.1.1ASC 4.1.2A
Required by
Section 508 · EN 301 549 (EU)
Broken
The accessibility problem illustrated: Motor:How many orders on Saturday?
01

The problem

Keyboard users can't read the chart's counts, which appear only in a tooltip while a pointer is on a bar.

02

Try it

Find Saturday’s count with the mouse, then try it with only the keyboard.

Point at Saturday’s bar and read the tooltip. Then put the mouse aside and press Tab: focus goes past the chart to “View all orders”, and no count is shown.

Apply a fix: the counts are printed on the bars, or Tab stops on the chart and the Left and Right arrow keys move the tooltip, with Escape to close it.

Broken Can you fix this?

BrokenCounts only in Chart.js's tooltip

Orders per day

Last week

View all orders

A recreated demo. The broken version is intentionally inaccessible.

03

The fix

Show every count without needing a pointer.

Before
BrokenCounts only in Chart.js's tooltip
<section class="card">  <h2>Orders per day</h2>  <p>Last week</p>  <canvas id="orders" role="img" aria-label="…"></canvas>  <a href="/orders">View all orders</a></section>
What is wrong2 points
  • The counts are drawn only in the tooltip, and the tooltip opens only while a pointer is on a bar.
  • The canvas takes no focus, so Tab goes past the chart, and no key opens a tooltip.
After

The counts printed on the bars

<section class="card">  <h2>Orders per day</h2>  <p>Last week</p>  <canvas id="orders" role="img" aria-label="…"></canvas>  <a href="/orders">View all orders</a></section>
How it is fixed3 steps
  1. Add chartjs-plugin-datalabels to this chart, in its plugins list, so each bar's value is painted with it.
  2. Set anchor: 'end' and align: 'end', so each count sits just above the top of its bar, where the eye already looks.
  3. Paint the counts in #1f2937, 14.68:1 against the white card, and give the chart 20 pixels of layout.padding at the top, so Saturday's 31 isn't cut off above the tallest bar.

This fixes the Before and passes 2.1.1: no count is left only in the tooltip, so there is nothing a keyboard has to open. The tooltip stays, for anyone pointing at a bar.

04

Design ideas

A chart can show its numbers without a hover.

A figure that follows both the pointer and the keys, beside a popular look that shows the counts only while the pointer is on the chart. Hover each sample, then try it with Tab and the arrow keys.

In the design file

  • Never leave a count only in what appears on hover; give the keyboard a way to bring up every one, or print them on the chart.
  • If the chart answers to the pointer, also draw the same moment reached with the keyboard, with the chart’s focus ring and the bar it is on.
  • Write which keys move from day to day beside the chart, such as the left and right arrow keys.
  • Set the counts at 4.5:1 or more against the chart’s background; the dark ink here is 14.76:1 on white.

Passes

  • Orders per day, last week

    20 ordersSunday

    Left and right arrow keys move between days.

    A big figure that follows the pointer and the keys Above the bars, “20 orders, Sunday” shows the latest day at rest. Point at a bar, tap it, or Tab to the chart and press the arrow keys, and the figure changes to that day, the bar turning a darker blue. Nothing floats over the bars, and the keyboard reaches every day.

Fails

  • Orders per day, last week

    Numbers that appear on hoverWCAG 2.1.1 At rest the chart is only bars; move the pointer onto it and every count fades in above its bar. It looks tidy, but Tab goes straight past, and nothing brings the numbers up from the keyboard.
05

Verify the fix

4 checks, no mouse.

Test with: Keyboard, Screen reader

0 of 4 checked

Record the OS, browser and assistive-technology versions, the build, the date, and the actual result of each step. Repeat whenever the chart component or its library is updated.

How screen readers handle role="status", aria-describedby and role="application" tabindex="0"

Limits

This is a starting pattern, not a guarantee for every chart. Chart is Chart.js, setActiveElements its own way to open a tooltip from code, and chartjs-plugin-datalabels a separate package from the Chart.js project; another library's equivalents go in their place. Screen readers differ in how they treat role="application", and some may keep the arrow keys for reading; test the complete dashboard with a keyboard and your target assistive technology.

This is a recreated teaching example, not a finding about a named client. The code is a starting pattern: test it in your own product. No completed assistive-technology test is claimed here.

EaseWeb service

Fixed it? Keep it from coming back.

I turn guides like this one into rules your coding agents follow and checks your CI runs. Then I retest by hand with a keyboard and screen readers, periodically.

See the service