liveBook · Manning

SVG desc element

As explained in D3.js in Action, Third Edition

An SVG desc element provides a longer textual description of an SVG graphic or graphical element.

An SVG <desc> element supplies a longer textual description of a graphic for screen reader users. Unlike a short <title>, it can describe the chart’s subject, conclusions, and significant trends. section 10.2.3

For an accessible visualization, give the SVG a role of img, connect its title and description with aria-labelledby, and append the <desc> element with a stable id. Place <title> first; place <desc> after it. section 10.2.3

A useful description should:

  • Identify what the visualization represents. section 10.2.3
  • State important conclusions and significant trends rather than merely repeating every visual label. section 10.2.3
  • Expose underlying data when users need a detailed equivalent experience, including values and categories for each datum. section 10.3

Accessible cetacean scatterplot

A scatterplot can describe 39 cetacean species, identify the blue whale as the largest, and report the Pantropical Spotted dolphin’s population. In D3, append <desc id="scatterplotDescription"> to the SVG and set aria-labelledby to reference the title and description. For changing datasets, generate the description from each datum’s name, population estimate, maximum size, maximum weight, and conservation status. section 10.2.3

How D3.js in Action, Third Edition covers it

How deep it goes
Explains purpose, placement, ARIA linkage, narrative content, and data-driven generation through working D3 code.
Examples
Uses a cetacean scatterplot, weight legend, color legend, and generated per-species descriptions as concrete accessibility examples.
What it assumes
Assumes familiarity with SVG containers and D3 selections while teaching the accessibility pattern through incremental chart code.
What you can do after
Apply it via D3 to connect an SVG’s title and description and expose chart context or underlying data to screen readers.
How it connects
Connects SVG accessibility with screen readers, the title element, ARIA labelling, semantic HTML, and data tables.

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.