Donuts too. I like donuts. But the same as pie, I don’t like them used as analytic visuals. I much prefer the Tree Map as a way to display category values as a percentage of the total. Let’s face it, pie charts are easy to understand. And even before the computer age, graphic designers could easily draw them by hand. The angle of any one slice of the pie can be calculated with a simple formula:
a = p/T * 360
Where a is the angle to be calculated for any one category, p is the numeric portion value of the category in question, and T is the sum total value of all categories (slices) in the pie. When Microsoft Excel started offering the ability to create pie charts for us based on some range of cells in the workbook, many latched on to them because they were just so easy. And their ease of creation led to wide spread adoption and quick understanding. The donut chart is basically a pie chart with the middle removed, leaving more of a ring shape.
Some time ago, the tree map was introduced as a way to display nested hierarchical data, all the while using the available space much more efficiently. (Wiki history can be found at https://en.wikipedia.org/wiki/Treemapping ) Let’s look at a side-by-side comparison of a pie chart and a tree map showing the same data categories and values, and occupying the same screen real estate. For this demo we’ll be using Microsoft Power BI and the Contoso Retail DW sample database. First, we’ll create each chart side by side to display Total Sales by Product Category Name, and we’ll include a ‘slicer’ in the middle that will allow us to filter by Continent Name later.
The result looks like this:
First off, the tree map absolutely fills the space made available to it, but the pie chart takes up less than a third of the box. (Yes, a third. Go get your ruler and calculator and do the math just like I did. We’ll wait.) Next, by default, the tree map shows the largest of its members in the upper left corner of the plot (“Home Appliances”, teal blue). The pie chart sorts alphabetically. (This is part of Microsoft’s product design and this pie chart can be sorted. Other products may or may not offer the same functionality.) Notice too how the tree map places the data labels inside its color plot? This eliminates the need for lead lines between a label and its plot, making for a cleaner graphic. Now let’s ‘slice’ both for Europe, and try to pinpoint the aqua green colored area, the smallest square. While the data label in the tree map is lost, it is retained in the pie chart. But, in the tree map it is easy to determine that this portion constitutes the smallest percentage of the whole by virtue of its placement in the lower right corner of the plot, while on the pie chart aqua green (“Audio”) and orange (“Music, Movies and Audio books”) look to be tied for last place. The tree map, however, offer a mouse-over area that is much easier to hit. The pie slice for Audio was about 4 to 6 pixels wide using the resolution I had when developing the charts, a hard target for a mouse over indeed!
Now let’s ramp things up a bit by adding an additional dimension: Region Country Name. The tree map handles this with ease, as show here:
The pie chart, when faced with the same task does not fare so well:
Note: The yellow triangle above the upper left corner of each chart indicates that not all data is shown due to the level of breakdown. Yeah, no kidding, even for the tree map. But the tree map does not attempt to label each and every breakdown in the plot. It does so where it can, where there is enough space, and leaves the smaller areas unlabeled. It’s purpose after all is to bring to light the largest portions and so the sacrifice is to minimalize the smaller ones. Here’s where Microsoft Power BI shines: the ability to cross-highlight elements in one chart based on what is selected in another. To demonstrate, we’ll first undo the Region Country Name breakdown on the pie chart, then highlight the “Germany” subsection of “Home Appliances” in the tree map. But before we do we’ll need some numbers and ratios. Home Appliance Sales in Europe accounts for roughly $840K, and the subset of Germany is $276K. Simple math tell us that ratio is about 33%. This is easy to visualize based on the size of the largest square inside “Home Appliances” in the tree map (the label is hidden by the pop-up). Along those same lines, it is easy to see that Germany makes up the better portion of Cameras and Camcorders (black), Computer sales (yellow), and TV and Video (purple).
Now watch what the 1/3 of Home Appliance sales (Germany) looks like when its ‘highlight’ is applied to the pie chart in Power BI by simply clicking on the square in the tree map:
I have added the red outlines to both charts for emphasis. The point of the comparison is this: The tree map visual is designed to represent a value relative to its neighbors by proportioning the size of the area it covers. And it’s designed to handle multiple dimensions or levels of a hierarchy, in our case, Product Category Name and Region Country Name. The pie chart on the other hand, can only really handle one dimension at a time effectively. The first dimension is represented by the angle of the pie, and assuming a perfect circle, that will translate into the area of the slice being proportional to its value. But introducing a second variable of any appreciable cardinality to a pie chart either makes it impossible to read as shown in the large pie chart above, or it attempts to plot the value by a relative radius inside the slice. The result of the latter is disastrous and misleading because it does not take into account the fact that the area highlighted is a function of the square of the radius. The red outlined pie sub slice is certainly NOT 1/3 of the total slice. More like 1/9th. (1/3rd squared) The tree map, as just explained, handles this seamlessly and elegantly. All this is not going to stop me from eating pie and donuts because, well, I really like pie and donuts. But I’m going to phase out their use in my future analytic exercises. Time to become a tree hugger!