Docs Menu

Top Item Chart

On this page

  • Top Item Chart Encoding Channels
  • Use Cases
  • Examples

Top Item charts show information from the document with the greatest or smallest value for a specified field.

When you create a Top Item chart, you specify:

  • The field by which to sort your collection.
  • Whether you want to sort in ascending or descending order.
  • The fields you want to display from the first document returned by your specified sort.

Top Item charts utilize the following encoding channels:

Encoding Channel
Description
Sort
The field by which to sort the collection. You can specify an ascending or descending sort.
Display
The fields to display from the top item in the collection after sorting.
Note

You cannot perform aggregations on Display fields.

Use Top Item charts to show information about the most extreme or most recent instance of a particular field value. For example, you can use Top Item charts to show information on:

  • The most recent reading from a collection of sensor data, such as temperature readings.
  • The highest rated movie in a collection.
  • The cheapest available room in a collection of available hotel listings.
  • The largest sale recorded in the past month (when combining a Top Item chart with date filters).

The following chart uses a data source containing Sample AirBnB Listing data and shows information on the document with the highest monthly_price in the collection:

Top Item Chart with AirBnB Data

The chart sorts the documents based on monthly_price in descending order, and returns the first document appearing in the sort.

The chart displays the following fields:

  • monthly_price
  • property_type
  • country
  • suburb
Give Feedback
© 2021 MongoDB, Inc.

About

  • Careers
  • Legal Notices
  • Privacy Notices
  • Security Information
  • Trust Center
© 2021 MongoDB, Inc.