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

Encoding Channels

MongoDB Charts provides various encoding channels to visualize your data based on the type of chart selected. Each encoding channel type provides different capabilities for processing and visualizing your data. The following table provides a brief description for each encoding channel type in MongoDB Charts:

Encoding Channel Type Description
Value A point on the chart is created from the chosen field for each document in the collection. You may only assign fields with a numeric or date type to a Value channel.
Category

Each unique value from this field in the collection is used as a chart category. The Category encoding channel provides the following additional visualization options:

  • For fields with a string data type, you can specify a field to sort on and the sort order.
  • For fields with a numeric data type, you can toggle data binning and select the bin size.
  • For fields with a date data type, you can toggle date grouping and select the grouping period.
Aggregation A point on the chart is created by applying an aggregation function over the values of this field from multiple documents; for example $count and $sum. For more information on aggregation in Charts, see the Aggregation section.

Aggregation

Dragging a field onto an aggregation encoding channel allows you to use an aggregation pipeline operator on that field. The aggregation operators available in the chart builder change based on the data type of the selected field. MongoDB Charts categorizes the field data type as either a number, string, or date and displays appropriate aggregation options accordingly.

Example

Donut charts provide two encoding channels:

  • A category channel called Label dictating which field to use when dividing the sections of the chart.
  • An aggregation channel called Arc dictating the aggregation operation to perform on the Label category.

The following donut chart examines NASA’s Landslide data source to show the frequency of various landslide triggers by performing a $count aggregation on the trigger field:

Donut chart example

We see from the chart that the most common landslide trigger is Downpour followed by Rain.

Multi-Series Charts

MongoDB Charts supports building multi-series charts, which split your chart data into groups, or series, to compare additional fields within your schema. There are two ways to create multi-series charts:

Multiple Field Mappings

MongoDB Charts allows you to map multiple aggregation or value encoding channels to a single chart property (e.g. X Axis or Y Axis). This allows you to compare additional fields in your visualization by creating new series based on the encoding channels added.

After dragging a field to an aggregation or value encoding channel, an additional optional encoding channel of the same type appears below the one which was just added, allowing you to add additional series to your visualization. This process repeats with each channel you add, so you can map as many fields as desired to your chart.

Example

The following multi-series column chart shows average movie ratings by genre from two different sources: IMDB and Rotten Tomatoes:

Movie Ratings Multiseries Chart

There are two aggregation encoding channels on the chart’s Y Axis, one for each of the site’s rating fields. By selecting the mean aggregation option, the chart aggregates these two fields using the $avg operator to provide a comparison of the average of two fields in the same column.

Tip

Use multiple field mappings to create a multi-series chart when the values being compared in the visualization come from two or more separate fields in the schema.

In the example above, there is one series for Rotten Tomato ratings and one series for IMDB ratings. Since these are separate fields within the schema, adding multiple aggregation encoding channels to map the data is the best choice to compare the fields.

Series Encoding Channel

You can also create multi-series charts by using the Series field in the chart builder. The Series field differs from aggregation encoding channels because it instead utilizes a Category encoding channel. When creating a series using the category encoding channel, each unique value from the data field becomes a series in the visualization.

Example

The following multi-series column chart shows order data from an office supply store, showing the most common items sold by store location:

Supply Store Series Encoding Channel Example

By using the item.name in the Series encoding channel, a series within each location group is added for each item name.

Tip

The Series field is useful when you are grouping data based on a discrete list of items. This approach should be used when the values for all series are stored in a single field, with a separate field used to establish the discrete categories.