MongoDB工具 >MongoDB图表 >Circular Charts > Donut Chart
On this page
Donut charts display data in a series of segments of a circle, with larger segments representing larger data values. The entire circle represents the sum of all data values, and each segment indicates the proportion of each category in the data to the total.
Donut charts provide the following encoding channels:
Encoding Channel | Description |
---|---|
Label | The category encoding channel. MongoDB Charts creates a segment in the donut for each unique value from this field. |
Arc | The aggregation encoding channel. MongoDB Charts aggregates this field based on the aggregation method selected. This field dictates the size of each circle segment. |
Donut charts are ideal for giving readers a quick overview of the proportional distribution of a dataset. Use donut charts when the general trend of data is more important than precise data values. Donut charts are especially useful when there is a low number of categories to visualize, because it is easier to compare fewer segments of the circle to see which values make up the greatest parts of the whole.
Consider using donut charts to display:
Note
Although you can bin or limit your data to reduce the number of categories in the visualization, this may not be the best choice for donut charts. The purpose of donut charts is to show each value as a proportion of a total, so excluding categories may result in a misleading visualization that reflects inaccurate proportions.
When looking to compare individual data values, rather than show values as a proportion to a whole, consider using a column or bar chart.
The maximum query response size for a donut chart is 5000 documents.
The following chart visualizes sales data from a mock office supply store. Each document in the collection represents an individual sale, which contains information on the item(s) sold and the customer conducting the purchase. This donut chart shows the proportional counts of the three different purchase methods the store provides:
The Label field of purchaseMethod
tells MongoDB Charts to
create a circle segment for each unique value in the purchaseMethod
field. MongoDB Charts proportions each segment according to the aggregated
value signified in the Arc encoding channel. In this case,
we aggregate to find the total count of documents with the
same purchaseMethod
value.
We see based on the visualization that the most common purchase method
is In store
, followed by Online
.
Note
In this example we are counting entire documents, so it does not matter what field we select for the Arc field. No matter what field we apply, the visualization will still be the same.
The following chart visualizes personal workout data. Each document in the collection represents a single workout activity, which includes information on the type of activity performed and the amount of time spent exercising. This donut chart shows the proportional time spent performing each exercise activity:
The Label field of Activity Type
tells MongoDB Charts to
create a circle segment for each unique value in the Activity Type
field. MongoDB Charts proportions each segment according to the aggregated
value signified in the Arc encoding channel. In this case,
we aggregate to find the total sum of workout times for
documents with the same Activity Type
value.
We see based on the visualization that the activity with the greatest
total workout time is Surf
, followed by Bike Ride
.