Bin, Sort, and Limit Your Data
On this page
You can bin, sort, and limit data in your charts to highlight key aspects in your data.
Bin Data
MongoDB Charts supports binning date, numeric, and string fields in your data. Binning breaks continuous data into discrete groups called bins, with each bin containing a contiguous subset of the original values. For example, you might group users into bins by the decade they were born, or group timestamped calendar events by the month of their start date.
Example
Continuous vs Discrete Data
Continuous data can occupy any value over a continuous range. Some examples of continuous data include height, temperature, or the time a person was born.
Alternatively, discrete data is data which can only take certain values, categorized into a classification. Examples of discrete data include eye color and the number of students in a class.
Sort Data
Use the Sort By dropdown in the Chart Builder to sort chart data by either:
Category
Value
Series field (for multi-series charts)
If you sort a multi-series chart generically by Value without sorting by a specific series, MongoDB Charts sorts your data based on the sum of all values in your series.
To toggle between ascending or descending sort order, click the a-z
button to the right of the Sort By dropdown.
By default, Charts sorts data based on Value in descending order.
Sort Multi-Series Charts by Series Value
If you create a multi-series chart using a different field per series, you can sort the chart by a specific series field.
Example
The following charts use the
Sample Data: Movies
data source to compare the mean number of fresh
and rotten
Rotten Tomato ratings for movies in each genre.
This chart is sorted by the mean fresh
value in descending
order:

This chart is sorted by the mean rotten
value in ascending
order:

Limit Data
You can apply a limit to the Category encoding channel to only include a specified number of categories in your visualization. The categories included are the first matching categories based on the sort order specified. Limiting data can be useful when visualizing data with so many categories it becomes difficult to create a meaningful chart.
When you limit your data, you may additionally enable Show "All Others" to create a new category called "All others" that combines the values of categories omitted by your limit.
Example
The following chart shows the average IMDb rating of movies from a particular country:

The dataset contains movies from many different countries, but it would be most interesting to see which countries produce the highest-rated movies. We can accomplish this by applying a limit to only show countries with the 10 highest average ratings for movies.
Switch the Limit Results toggle to On
and leave the
Show input at the default value of 10.
Check Show "All Others" to create an 11th column representing the average rating of movies from countries that aren't in the top 10.
The chart is now much easier to understand, and we have a clear view of the countries with the highest-rated movies:
