top of page
hand-businesswoman-touching-hand-artificial-intelligence-meaning-technology-connection-go-
kinjaltanna

Yummy Tableau Donut! Expanding Donut Chart

Over time, we have come across various data visualization styles and tools. However, as many tools were there, there were also significant downsides to them. For example, if we are comparing sales of different departments of an organization, using all the previous tools we could get to know which department is leading the race, but wouldn’t be able to know the whole number of sales. So, this is the point where the Donut chart comes into action.

I wanted to share an interactive version of a donut chart. By the end of this blog, you’ll be able to create an interactive donut chart that expands to show more detail when a user hovers over one of the slices. Let’s get started.

Create a basic Donut Chart

Start with a simple donut chart using Category and Sales from the Sample Superstore dataset. First, we’ll add a placeholder field which will allow us to create the dual axis used to achieve the donut chart look. Use the calculated field SUM (0) by double-clicking on the Columns shelf and typing in the formula. On your sheet, change the Mark type to Pie. Drag Category onto the Color property of the Marks card and drag Sales onto Angle or Size.

Next, hold Ctrl then click and drag the placeholder field so that it’s duplicated on the Columns shelf. You should have a view that looks like this:




From here, it’s simple to transform our two pie charts into the donut chart. Click the Marks card for the second placeholder field. Remove Category from the Color property and Sales from the Angle property. Switch the Mark type to Circle, then change the color of the circle to white or whatever color you’re using as your dashboard background. Right-click on the second placeholder field and choose Dual Axis. Finally, resize the white circle so it fits inside your pie chart. Before I move on, I’m going to sort my Category field in descending order by Sales and remove all borders, gridlines, and zero lines.



Our next step is to create a donut chart for the Sub-Category field, which will expand out from our original donut chart. To save some time and clicks, duplicate the Category donut chart sheet. Add Sub-Category to the Detail property of the Marks card, not the Color property. The Color property will come into play in the next few steps. For now, this donut chart will appear unchanged compared to the first one we created.

Create Interactivity with Parameter Actions

Let’s get into setting up the interactivity of this view. Right-click on the Category pill in the Data pane and go to Create and click Parameter. I renamed my parameter “Focus Category”. Add a value called “Reset”. This will allow us to “reset” the view and hide the Sub-Category expansion.



We need two calculated fields to focus on a specific Category and its Sub-Categories.





The second calculated field tells which Category we want to highlight by concatenating either ‘t’ or ‘f’ from the Category Filter calculation (a Boolean value that needs to be converted to a string) and the Category name.

Replace Category on the Color property of the Marks card with Category Filter Color. Sort descending order by Sales. Show the parameter control for Focus Category. Your color legend should look something like this:













Now we need to map our colors so that every combination of “f+[Category]” is mapped to white (or your dashboard background color), and that every combination of “t+[Category]” is mapped to a highlight color.









Before we add these donut charts to our dashboard, let’s take a few more formatting steps to polish these views. First, update the colors on the Category donut so that they’re in the same color family as the colors on the Sub-Category donut. I decided to make the Category donut slices a slightly darker version of each color on the Sub-Category donut chart. I used the built-in Green-Orange-Teal color palette from Tableau, but feel free to use any colors you’d like.

Next, add a label to the Category donut chart that says, “Sales by Category”. To achieve this, I created a placeholder calculated field and dragged it onto the Label property of the Marks card, then formatted it to my liking:





Now add a white border to our donut slices by clicking on the Color property of the Marks card, clicking on the Border dropdown, and choosing White. Complete this step for both the Category and Sub-Category donut charts.

We need two calculated fields to have dynamic Sub-Category labels and tooltips that only show up for the highlighted Category. The formula for the dynamic Category Text labels is as follows:






The formula for dynamic Category sales labels is similar. Once I created the calculated field, I changed the default number formatting to show currency in $.





Drag these two new calculated fields onto the Label property of the Marks card for your Sub-Category donut chart. Next, update your tooltip so that it only uses the dynamic fields, labels and tooltips that only show the Category being highlighted!

Okay, we’re ready to start our dashboard. Add your Sub-Category sheet to the dashboard first. Make the sheet for the Category donut transparent by clicking on Format > Shading and under Worksheet choosing “None”, and then add it to the dashboard. Size your donuts and sheets until they line up correctly. In other words, make sure your Category donut fits inside your Sub-Category donut with even spacing between each chart. This might take a few tries to get exactly right.

Now we’ll create the magic of the expanding donut chart. Select Dashboard > Actions. Click Add Action, then Change Parameter. We’ll use our Category donut chart as the source sheet to change our focus Category, which will show the corresponding Sub-Category donut slices. To hide the Sub-Category expansion when you remove your mouse from the view, under “Clearing the selection will” select “Set value to” and type “Reset” so that it matches your parameter.




The Donut





63 views0 comments

Recent Posts

See All

BASIC JAVA

What is Java Java is a widely-used programming language for coding web applications. Java is a multi-platform, object-oriented, and...

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page