11 Hierarchical visualizations

 

This chapter covers

  • Constructing a root node from hierarchical data
  • Using hierarchical layout generators
  • Drawing a circle pack
  • Drawing a tree chart

In the early chapters of this book, we used data visualizations to encode numerical data. For example, the length of the bars in the bar chart from chapter 3 represented the number of related survey responses. Similarly, the position of data points in chapter 4’s line chart depicted temperature. In this chapter, we’ll discuss hierarchical visualizations, which encode parent-child relationships and can reveal patterns that would go unnoticed with the simpler visualizations we’ve worked with so far.

Hierarchical visualizations communicate parent-child relationships via enclosure, connections, or adjacency. Figure 11.1 shows two examples of hierarchical visualizations that use enclosure: the circle pack and the treemap. As its name says, the circle pack is a group of circles. There’s a root parent, the most outer circle, and subsequent levels of children called nodes. All children of a node are “packed” into that node, and the size of the circles is proportional to the number of nodes they contain. The size of the leaf nodes, the children at the lowest level, can represent an arbitrary property. The treemap works similarly but uses nested rectangles instead of circles. Treemaps can be more space efficient than circle packs, and we often meet them in visualizations related to finances.

11.1 Formatting hierarchical data

11.1.1 Working with a CSV file

11.1.2 Working with a hierarchical JSON file

11.2 Building a circle pack chart

11.2.1 Generating the pack layout

11.2.2 Drawing the circle pack

11.2.3 Adding labels

11.3 Building a tree chart

11.3.1 Generating the tree layout

11.3.2 Drawing the tree chart

11.4 Building other hierarchical visualizations

Summary