Docs Menu
Docs Home
Atlas Charts
/ /

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.


In the Select Data Source modal that appears:

  1. Click the Project tab.

  2. Click the name of the deployment that contains the sample data source.

  3. Click the sample_supplies database. The database's data sources appear.

  1. Click Select on the sales data source.

  1. In the Chart Type dropdown, select Circular.

  2. 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.

  1. In the Fields section click the items field to expand the items object and view its properties.

  2. 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.

  3. In the array reduction dropdown for the items array select Unwind array.

  4. In the array reduction dropdowns for the tags select Array element by index. Using this option you can specify which element of the tags array to visualize.

  5. Enter 0 for the Index input to only visualize the first element of the tags 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.


    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.

  6. Drag the id field to the Arc encoding channel.

  7. 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:

Donut Chart Builder
click to enlarge
{ storeLocation: { $in: [ "Denver", "New York" ] }, 'items.price': {$gte: 1200} }

This filter specifies that Charts only visualizes item tags from items sold from either the Denver or New York store location where there was an item in the sale costing $1200 or more.


Your chart should now look something like this:

Edit Chart Add Filter
click to enlarge

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.

  1. Hover over your chart title and click the pencil icon.

  2. Copy the following into the chart title input:

    Frequency of Item Tags from Sales in Denver and New York with Price Threshold
  3. Click the check mark to save your title.


Your dashboard should now look something like this:

Order Tutorial Dashboard Stage 2
click to enlarge

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.

← Column Chart Showing Total Sales by Store Location