Navigation
This documentation refers to the on premises version of MongoDB Charts. For documentation on the MongoDB Charts SaaS application in Atlas, click here.

Column and Bar Chart Reference

Column and bar charts plot data in either horizontal or vetical segments where the length of the segment is proportional to the data value. Column and bar charts provide high-level overviews of data trends by comparing values within a specific category.

Column and Bar Chart Encoding Channels

Column and bar charts provide the following encoding channels:

Encoding Channel Description
X / Y Axis
  • In the category axis encoding channel, a bar or column is rendered for each unique value from this field.

    In a column chart, the category is the X Axis, which results in vertical segments. In a bar chart, the category is the Y Axis, which results in horizontal segments.

  • The aggregation axis encoding channel dictates which field to aggregate on and the type of aggregation to perform. This ultimately dictates the size of each bar or column.

    Note

    You can aggregate upon multiple fields in your dataset to create multi-series charts. For more information, see Multiple Field Mappings.

Series

(Optional) A category encoding channel that segments the axis category based on the unique values in this field.

If omitted, MongoDB Charts renders a basic bar or column chart with just a comparison of the X Axis and Y Axis fields.

Note

This option is only available for Grouped and Stacked charts with a single field mapped in the aggregation channel.

Color

(Optional) An aggregation encoding channel for Colored charts that changes the bars or columns’ colors to reflect the aggregated value of the field, with darker colors meaning greater values.

If omitted, MongoDB Charts renders a basic bar or column chart with just a comparison of the X Axis and Y Axis fields.

Column and Bar Chart Types

Column and bar charts provide the following sub-types:

Sub-Type Name Description
Grouped

MongoDB Charts groups data by the category specified in the category encoding channel, and plots a bar or column for each value in the Series encoding channel.

Grouped Column Chart Reference Small

For a more detailed example, refer to the grouped column chart example.

Stacked

MongoDB Charts creates a bar or column for each distinct value in the category encoding channel field, and splits each bar or column into segments based on the the Series encoding channel.

Stacked Bar Chart Reference Small

For a more detailed example, refer to the stacked bar chart example.

Colored

MongoDB Charts creates a bar or column for each distinct value in the category encoding channel field, and the Color encoding channel changes the color of each bar / column based on the aggregated value of the value specified in the encoding channel.

Colored Bar Chart Reference Small

For a more detailed example, refer to the colored bar chart example.

Use Cases

Column and bar charts display information in similar manners and, as such, have similar use cases. There are, however, situations where it may be beneficial to use one over the other:

  • A bar chart may be a better choice than a column chart when the category labels are long, as it may be difficult to quickly pinpoint which label applies to which column.
  • A column chart may be a better choice when comparing sequential values (such as time or geographic data) because the viewer will intuitively read these charts from left to right and attain the full picture of the visualization.

Tip

Column and bar charts are best suited for data with limited categories. When plotting data with many categories, such as years across a long period of time, consider using a Line Chart.

You can also limit the number of categories displayed in your chart to focus on a subset of your data. MongoDB Charts provides the following methods to reduce the number of bars or columns plotted in the visualization:

Examples

Grouped Column Chart

The following grouped column chart shows the most common items sold from an office supply store across several store locations.

The X Axis category of storeLocation creates a group for each store location in the data set, and each group is split by the series column of item.name. This ultimately displays the count of each item’s name sold at each store location:

Grouped Column Chart Reference

Stacked Column Chart

The following stacked column chart shows the number of awards won by the top 10 highest award-winning movie directors, with each bar segmented by the genres of films directed by that director.

The X Axis category of director creates a column for each director in the data set, which we limit to only the top 10 as sorted by the aggregated sum of awards.wins from the Y Axis. The Series encoding channel field of genres segments each column to portray the genres of the films directed by that director:

Stacked Column Chart Reference

Colored Bar Chart

The following colored bar chart shows the average Rotten Tomatoes rating for countries with the 10 highest ratings, and colors each bar to show the average runtime for movies from each country.

The Y Axis category creates a bar for each country in the data set, which we limit to only the top 10 as sorted by the aggregated mean of the tomato.rating field from the X Axis. The Color encoding channel field of runtime colors each bar to show the average runtime for movies from each country. A darker shade of green indicates a longer average runtime:

Colored Bar Chart Reference