|
| 1 | +.. _top-item-ref: |
| 2 | + |
| 3 | +============== |
| 4 | +Top Item Chart |
| 5 | +============== |
| 6 | + |
| 7 | +.. default-domain:: mongodb |
| 8 | + |
| 9 | +.. contents:: On this page |
| 10 | + :local: |
| 11 | + :backlinks: none |
| 12 | + :depth: 1 |
| 13 | + :class: singlecol |
| 14 | + |
| 15 | +Top Item charts show information from the document with the |
| 16 | +greatest or smallest value for a specified field. |
| 17 | + |
| 18 | +When you create a Top Item chart, you specify: |
| 19 | + |
| 20 | +- The field by which to sort your collection. |
| 21 | + |
| 22 | +- Whether you want to sort in ascending or descending order. |
| 23 | + |
| 24 | +- The fields you want to display from the first document returned by |
| 25 | + your specified sort. |
| 26 | + |
| 27 | +Encoding Channels |
| 28 | +----------------- |
| 29 | + |
| 30 | +Top Item charts utilize the following :ref:`encoding channels |
| 31 | +<encoding-channels>`: |
| 32 | + |
| 33 | +.. list-table:: |
| 34 | + :header-rows: 1 |
| 35 | + :widths: 20 80 |
| 36 | + |
| 37 | + * - Encoding Channel |
| 38 | + - Description |
| 39 | + |
| 40 | + * - Sort |
| 41 | + - The field by which to sort the collection. You can specify an |
| 42 | + ascending or descending sort. |
| 43 | + |
| 44 | + * - Display |
| 45 | + - The fields to display from the top item in the collection after |
| 46 | + sorting. |
| 47 | + |
| 48 | +.. note:: |
| 49 | + |
| 50 | + You cannot perform aggregations on :guilabel:`Display` |
| 51 | + fields. |
| 52 | + |
| 53 | +Use Cases |
| 54 | +--------- |
| 55 | + |
| 56 | +Use Top Item charts to show information about the most extreme or most |
| 57 | +recent instance of a particular field value. For example, you can use |
| 58 | +Top Item charts to show information on: |
| 59 | + |
| 60 | +- The most recent reading from a collection of sensor data, such as |
| 61 | + temperature readings. |
| 62 | + |
| 63 | +- The highest rated movie in a collection. |
| 64 | + |
| 65 | +- The cheapest available room in a collection of available hotel |
| 66 | + listings. |
| 67 | + |
| 68 | +- The largest sale recorded in the past month (when combining a Top |
| 69 | + Item chart with :ref:`date filters <charts-filter-documents>`). |
| 70 | + |
| 71 | +Example |
| 72 | +------- |
| 73 | + |
| 74 | +The following chart uses a data source containing :atlas:`Sample AirBnB |
| 75 | +Listing </sample-data/sample-airbnb/>` data and shows information on the |
| 76 | +document with the highest ``monthly_price`` in the collection: |
| 77 | + |
| 78 | +.. figure:: /images/charts/top-item-example.png |
| 79 | + :figwidth: 700px |
| 80 | + :alt: Top Item Chart with AirBnB Data |
| 81 | + |
| 82 | +The chart sorts the documents based on ``monthly_price`` in |
| 83 | +descending order, and returns the first document appearing in the sort. |
| 84 | + |
| 85 | +The chart displays the following fields: |
| 86 | + |
| 87 | +- ``monthly_price`` |
| 88 | + |
| 89 | +- ``property_type`` |
| 90 | + |
| 91 | +- ``country`` |
| 92 | + |
| 93 | +- ``suburb`` |
0 commit comments