When the moon hits your eye (chart), like a big pizza pie (chart)
Pie charts are a very common way of presenting simple quantitative data, but they have their own limitations--people have greater difficulty perceiving the size of an area when it's in a circular shape, and you really need to make sure that the wedges are ordered descending clockwise from the top in order to be able to adequately compare them. That said, they're common enough that knowing how to make them is an incredibly useful skill as anyone doing data visualization work will at some point be asked for one.
D3's pie chart layout resides in the d3-shape
package and is somewhere between the layouts of the last chapter and the line generators of Chapter 3, Shape Primitives of D3. We create a pie chart layout and pass it an array of numbers and then pass that to an arc generator to create our pie chart. Let's get to it.
We start by filtering out people who have less than 60 minutes of screen time and creating a pie generator...