Hierarchical layouts

All hierarchical layouts are based on an abstract hierarchy layout designed for representing hierarchical data—data within data within data within data within.... all the way down. As mentioned earlier, imagine a tree, or an org chart if you don't go outside very much.

All of the common code for the partition, tree, cluster, pack, and treemap layouts is defined in d3.layout.hierarchy(), and they all follow similar design patterns. The layouts are so similar that the official documentation very obviously copy-pastes most of its explanations which are practically identical. Let's avoid that by looking at the common stuff first, and then we will focus on the differences.

First of all, we need some hierarchical data. There's an ...

Get D3.js: Cutting-edge Data Visualization now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.