# How a chart calculates its values

A chart view starts from the items that the view's filters allow. It sorts them into categories by a field, and calculates one value per category for each measure. The chart type only decides how those values are drawn.

## Chart types

| Type | What it draws |
|---|---|
| **Bar** | one bar per category |
| **Line** | one point per category, joined |
| **Area** | a line with the space under it filled |
| **Pie** and **Donut** | one slice per category |
| **Number** | one figure per measure, no axis |
| **Scatter** | one point per item, placed by two of its values |
| **Flow over time** | the items in each value, or scope against done, day by day |

**Scatter** and **Flow over time** have no categories or measures of their own. [How cycle time and flow charts work](../flow-metrics/) explains them.

## What a measure counts

- **Count (items)** counts items, and needs no field.
- **Count with value** counts items whose field is filled.
- **Count values** counts every value, so a multi-value field counts each one.
- **Distinct count** counts how many different values appear.
- **Sum**, **Average**, **Min**, **Max**, **Median** and **% of total** read number fields, formula fields whose result is a number, and tracked time. They also read the **Cost** field, and History durations such as **Cycle time**.

## Rolled-up totals

With **Use rolled-up totals**, a measure reads each parent item's rolled-up total. The items below that parent are then skipped, so nothing is counted twice.

**Cost** has no **Use rolled-up totals**. Its figure already covers the items below, so an item below another item in the chart is counted inside that item. An item whose type **Cost** does not apply to has no figure, so the items below it count instead, in its category.

A measure switched from a sum of **Cost** to **Count (items)** keeps **Cost**. The measure then counts the items whose figures the sum added up, not every item. Its name says so: **Count of items with a Cost figure**.

**Cost** cannot be the field of the categories or of **Break down by**. Besides a measure, it can be the **Y-axis** of a scatter or the **Sum** of a flow over time chart. [How cycle time and flow charts work](../flow-metrics/) explains both.

## Several measures

- A bar, line or area chart can hold up to three measures, for example a budget and its cost.
- A chart has either a breakdown or several measures, never both.
- A pie or donut draws the first measure only. The other measures are kept for when the type changes back.
- With several measures, each measure has its own colour and a name in the legend.

## Kinds of value and axes

- Each measure gives one kind of value: money, hours, a duration, a count, a percentage or a plain number. A duration is a History duration such as **Cycle time**, drawn in days, or in hours when the tallest bar is under a day.
- A chart shows at most two kinds. The pickers leave out a choice that would add a third.
- The second kind of value is drawn against its own axis. That axis is on the right of a vertical chart and at the top of a horizontal one.

## Number format

Numbers and amounts follow your organization's number format and currency. Tracked time shows as hours and minutes, or as decimal hours when its field is set to decimal hours.

## Stacking, sort and top categories

- **100% stacked** draws each segment as its share of the category. The tooltip shows the share and the value.
- A value sort can name the measure it sorts by.
- **Show top** keeps the first categories in the chart's sort order. Under the default sort, **Value (high → low)**, those are the largest. The rest can be grouped as "Other". The "Other" value is calculated again from the items of the dropped categories, so an average stays a true average.

## Example

A bar chart counts items by **Status**, sorted **Value (high → low)**. Five statuses hold 12, 8, 5, 3 and 2 items. With **Show top** set to 3 and the rest grouped as "Other", the chart draws bars of 12, 8 and 5, and an "Other" bar of 5.

Sort the same chart by **Label (A → Z)** and **Show top** keeps the first three statuses in alphabetical order, whatever their counts.

## Next

- [Chart view](../../views/chart-view/)
- [How values roll up to a parent](../rollups/)
