liveBook · Manning

Color blindness

As explained in D3.js in Action, Third Edition

Color blindness is a visual condition involving reduced ability to distinguish certain colors or their brightness differences.

Color blindness reduces the ability to distinguish some colors, shades, or brightness levels. A categorical palette can therefore make chart categories difficult to identify. section 10.2.2

Accessible visualizations should not communicate essential information through color alone. Double encoding pairs color with another channel, such as patterns or shapes. section 10.2.2 section 10.3

A practical pattern-based workflow is:

  • Check the palette with a WCAG color-contrast checker and improve contrast against the background. section 10.2.2 section 10.3
  • Append a defs element to the SVG, then create pattern tiles containing lines, dots, or other shapes. section 10.2.2 section 10.3
  • Apply a status-specific pattern to every data mark and repeat the same encoding in the legend. section 10.2.2

Pattern-encoded scatterplot

Create an SVG pattern for each conservation status, then assign it with a status-to-pattern function: d3.selectAll(".cetacean").attr("fill", d => getPattern(d.status)). A horizontal-line pattern can be built from a white rectangle and an SVG line inside a repeated tile.

How D3.js in Action, Third Edition covers it

How deep it goes
Explains perception challenges, contrast checks, SVG pattern construction, mark updates, and legend application.
Examples
Uses a cetacean conservation scatterplot with status-specific lines, dots, stars, and other SVG patterns.
What it assumes
Assumes a categorical color palette and an SVG visualization, while teaching double encoding and pattern creation.
What you can do after
Build it from scratch with D3 and SVG by testing contrast and adding patterned encodings to marks and legends.
How it connects
Connects color blindness with accessibility, categorical color palettes, contrast, double encoding, SVG patterns, and legends.

Also explained in

Compare how 2 books explain color blindness →

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.