Lesson

Master the bar chart visualization

Create a bar chart and customize it with visualization settings.

We’ll walk through creating a bar chart and editing that bar chart’s settings, then talk about stacked bar charts and when we might want to use them.

Create a bar chart

You can follow along using Metabase’s Sample Database. Select + New > Question > Raw data > Sample database. Choose the Sample Database’s Orders table as your data. Next, summarize the count of rows and group by Product -> Category. Your notebook should look like figure 1.

<em>Fig. 1</em>. Notebook of question that summarizes the count of orders grouped by product category.
Fig. 1. Notebook of question that summarizes the count of orders grouped by product category.

Click Visualize, and Metabase will present the data as a bar chart:

<em>Fig. 2</em>. The humble bar chart.
Fig. 2. The humble bar chart.

Bar chart settings

Click on the Settings button at the bottom left of the chart to see all our tools:

Display settings

In the Settings > Display section, we can add a goal line that specifies where we want the values to be and Metabase can alert us when the values exceed (or drop below) that goal. In figure 3, we add a goal line at 5500 and name it Arbitrary Sales Goal.

<em>Fig. 3</em>. Adding a goal line for our arbitrary sales goal.'
Fig. 3. Adding a goal line for our arbitrary sales goal.'

Toggling on Show values places the count values above each column.

Clicking the color swatch at the bottom of the sidebar will open a color palette to set the bar color.

We can also set the display to a stacked bar chart, which we’ll get into in a bit.

Axes

Select Axes in the Settings sidebar.

Here we can specify how we want our table organized.

Y-axis gives three options:

  • Linear
  • Power
  • Log

The linear option is selected automatically, and for our example provides the most accurate representation of our data, so we’ll keep it.

With the Show lines and marks options we can change the way the categories and quantities are represented on each axis. The options for the y-axis are hide and show, while the x-axis has several more:

  • Hide
  • Show
  • Compact
  • Rotate 45˚
  • Rotate 90˚

Labels

Select the Labels button in the Settings sidebar. Here we can hide or customize axes labels.

Stacked bar charts

If the data we’re visualizing can be broken down into multiple categories within a whole, we could consider using a stacked bar chart. A 100% stacked bar chart is similar, but displays those parts as relative percentages, so every bar spans the full y-axis.

To create a stacked bar chart, click on Settings > Display and select either Stack or Stack - 100%.

Let’s say we wanted to see how many orders were placed per product category across different quarters of a year. Here’s that example displayed in three different bar chart styles:

<em>Fig. 4</em>. An unstacked multi-series bar chart.
Fig. 4. An unstacked multi-series bar chart.
<em>Fig. 5</em>. A standard stacked bar chart.
Fig. 5. A standard stacked bar chart.
<em>Fig. 6</em>. A 100% stacked bar chart.
Fig. 6. A 100% stacked bar chart.

It may take some back-and-forth to figure out which display settings are right for your data, so try a few different options to see what works best for you and your team.

Further reading

Thanks for your feedback!

Get articles like this one in your inbox every month