liveBook · Manning

Leaf node

As explained in D3.js in Action, Third Edition

A leaf node is a node at the lowest level of a hierarchy with no child nodes.

A leaf node is a node at the lowest level of a hierarchy: it has no child nodes. A hierarchy has one root, branches through intermediate nodes, and ends with leaves. In a language-family visualization, the languages form the leaf nodes. section 11.0

D3 represents hierarchical data with a root object. Its leaves() method returns only nodes without children, while descendants() returns every node. This distinction is useful when a chart needs leaf-specific values, such as sizing circles by the number of language speakers. section 11.5 section 11.3.2

In a D3 tree chart, leaf nodes receive specialized visual treatment:

  • Select the complete descendants array so that links, intermediate nodes, and leaves can be drawn together. section 11.3.2
  • Identify leaves through the absence of children or, in the demonstrated dataset, a terminal depth value. section 11.3.2
Figure 11.2 A hierarchical visualization has one single root that separates into one or more branches. It ends with leaf nodes, which in this example are the languages.
figure

Use the hierarchy diagram to trace how one root separates into branches and terminates in language leaf nodes. section 11.0

How D3.js in Action, Third Edition covers it

How deep it goes
Explains leaf detection, D3 extraction, sizing, coloring, and labeling, but stops short of broader hierarchy algorithms.
Examples
Uses languages grouped by family, with leaf-circle size representing total speakers and labels placed beside terminal nodes.
What it assumes
Assumes basic hierarchical data and D3 data binding while showing how root, descendants(), and leaves() support chart construction.
What you can do after
Build it from scratch by extracting leaves from D3 hierarchies and rendering them with distinct SVG size, color, and label rules.
How it connects
Connects leaf nodes to hierarchical visualization, tree charts, circle packs, treemaps, d3.hierarchy(), d3.stratify(), and descendants().

Also explained in

Compare how 10 books explain leaf node →

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.