- Tutorials >
- Visualizing Order Data >
- Donut Chart Showing Most Common Tags for Items Sold
Donut Chart Showing Most Common Tags for Items Sold¶
Time to Complete: 5 minutes
Next we will add a chart where you can quickly see which types of items the company is selling the most of. This information will be helpful for the company marketing team to know how effectively direct advertising.
In this scenario, your manager has expressed interest specifically
in items sold from the Denver
and New York
store locations.
Additionally, they have requested to only visualize sales which
contain an item costing $1200
or more, in an effort to more closely
examine the new line of laptops being sold at these locations and what
types of items are being bought with them. You can accomplish this
using a filter in your
donut chart, as shown in the following
procedure.
Construct the Chart¶
At the top-right corner of the dashboard, click Add Chart.¶
In the Data Source dropdown, select test.supplySales.¶
Select the Chart Type¶
- In the Chart Type dropdown, select Circular.
- Click Donut below the dropdown.
Donut Chart
A donut chart is a good choice for this chart because donut charts show the relationship of parts to a whole. Using this chart type you can easily get an idea of which tags make up the greatest portion of total sales.
Add the desired fields to the proper encoding channels.¶
In the Fields section click the
items
field to expand theitems
object and view its properties.Drag the
items.tags
field to the Label encoding channel. The Label encoding channel dictates which field to use when dividing the sections of the chart.In the array reduction dropdown for the
items
array select Unwind array.Unwind Array
Unwinding the array creates a new document for each element of the
items
array, so each item from each sale is used in the chart.In the array reduction dropdowns for the
tags
select Array element by index. Using this option you can specify which element of thetags
array to visualize.Enter
0
for the Index input to only visualize the first element of thetags
array. The first item tag is the most relevant tag to the item, so it should be the main concern in the visualiztion. This is the primary item tag.Note
Selecting an array element by index also ensures the chart does not get overcrowded with less important tags as it would had you chosen to unwind the
tags
array rather than select a specific element.Drag the
items.tags
field to the Arc encoding channel.Arc Encoding Channel
The Arc encoding channel dictates which field to aggregate upon in the chart. Using the
items.tags
field here, you can select an aggregation option which will provide the number of occurrences of each item tag.Repeat steps
c-e
for the Arc encoding channel.Note
When constructing donut charts, most often you will be using the same field for both the Label and Arc encoding channels.
In the Aggregate dropdown, select count. This option counts the occurrences of the first tag of each item and adds them to the chart.
Your chart should now look something like this:

Click Apply to the right of the filter.¶
Your chart should now look something like this:

Notice how the electronics
tag now takes a larger slice of the
distribution compared to when not using the filter. Based on this
chart, notice that office
and school
are the two most common
primary item tags from sales matching the filter.
Title your chart.¶
Hover over your chart title and click the pencil icon.
Copy the following into the chart title input:
Click the green check mark to save your title.
Click Save and Close at the top-left of the chart builder view.¶
Your dashboard should now look something like this:

Next Steps¶
Now that we have a chart showing the tags of the items sold, it would be helpful to know which specific items are most commonly sold at the various store locations. To do so, refer to the next section to see how to implement a grouped column chart showing the most common items sold by store location.