liveBook · Manning

Accessibility

As explained in D3.js in Action, Third Edition

Accessibility is the design of digital content and interfaces so that people with varying abilities can perceive, understand, navigate, and use them.

An accessible visualization gives people with varying abilities an equivalent way to reach its main conclusions and, when useful, its underlying data. An equivalent experience need not look or work identically for everyone. Plan for it while building the chart: clear explanations, readable visuals, screen-reader access, keyboard controls, and responsive layouts are easier to add from the start than to retrofit. section 10.0

The Web Content Accessibility Guidelines organize the goal into four principles: perceivable, operable, understandable, and robust. For a chart, that means asking whether its information can be perceived without relying on sight or color alone, its controls can be operated with a keyboard, its instructions make sense, and assistive technologies can interpret it. Chartability turns such questions into tests for visualizations. section 10.2

Table 10.1 Accessibility checklist for D3.js projects
Textual information
The chart’s purpose and how to read, use, and interpret it are explained.
All text targets a reading grade level of 9 or lower.
Text size is at least 12 px, ideally larger.
Visual information
Colors provide sufficient contrast.
Information isn’t communicated with color alone.
Data is presented at an appropriate density.
Screen readers access
The markup is semantic.
The SVG container provides additional context.
The visualized data is read by screen readers.
A data table is provided as an alternative.
Custom keyboard and touch controls don’t override screen reader settings.
Interactions
Users can operate interactions with a keyboard.
Navigation and interaction are easy and not labor-intensive.
Interaction cues are provided.
Other considerations
The project offers an equivalent experience on all screen sizes.
Style changes made by the user aren’t overridden.
Visuals don’t present a risk of seizure.

Use the checklist to inspect textual information, visual information, screen-reader access, interactions, and the experience across screen sizes. section 10.2

Work through the chart as a reader would:

  • Explain the chart’s purpose, what its marks represent, how to interpret position, size, and color, and how to use its controls. Label axes and provide legends. Aim for text at reading grade level 9 or lower; define necessary technical terms. section 10.2.1
  • Check text size at every screen width. Text inside a responsive SVG can shrink with the drawing; a D3 linear scale and resize handler can adjust axis-label and tick-label sizes as the window changes. section 10.2.1
  • Check contrast, avoid conveying information through color alone, and keep data at an appropriate density. section 10.2
  • Use semantic HTML for the page, lists for groups of controls, and button states such as aria-pressed. Give an SVG a descriptive title and description so a screen reader has context beyond its individual labels. section 10.2.3
  • Offer the data in a table, make interactions reachable by keyboard, and check that the layout remains usable on small screens. section 10.2.3 section 10.3

Give a scatterplot a readable alternative

For a scatterplot of cetacean species, describe what each circle and its position, area, and color mean. Add a title and description to the SVG, connect them with aria-labelledby, and set role="img". A generated description can name each species and its population estimate, maximum size, maximum weight, and conservation status. Provide a separate data table with column headers and a CSV download link; buttons can switch between chart and table while updating aria-pressed. section 10.2.1 section 10.2.3

Finally, respect readers’ settings and comfort. Avoid inline styles for general page typography and color when they could override a user’s stylesheet. Check the legend and scatterplot on small screens, and avoid red flashes or large red areas that may present a seizure risk. section 10.2.5

How D3.js in Action, Third Edition covers it

How deep it goes
Works through a testable checklist and concrete chart changes, while leaving the full set of Chartability tests for further work.
Examples
Uses a cetacean scatterplot, readability checks, responsive axis labels, SVG descriptions, and a switchable data table.
What it assumes
Starts with an existing D3.js scatterplot and introduces WCAG principles and Chartability tests before applying them.
What you can do after
Apply it via D3.js, semantic HTML, and SVG to improve a chart’s descriptions, data access, and interaction.
How it connects
Connects WCAG and Chartability with responsive design, semantic HTML, SVG descriptions, screen readers, keyboard navigation, and data tables.

Also explained in

Compare how 6 books explain accessibility →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of D3.js in Action, Third Edition. The section links point to the parts of the book it draws on.