# chart_pie

Plots events on an pie chart.

```tql
chart_pie x|label=field, y|value=any, [group=any]
```

## Description

Visualizes events with an pie chart on the [Tenzir Platform](https://app.tenzir.com).

### `x|label = field`

Name of each slice on the chart.

String, IP, subnet, and `null` labels use the order in which they first appear in the input. Use [`sort`](https://preview.docs.tenzir.com/375/375/reference/operators/sort.md) before [`chart_pie`](https://preview.docs.tenzir.com/375/375/reference/operators/chart_pie.md) to control the order of categorical slices.

Numeric, duration, and timestamp labels are sorted by value.

### `y|value = any`

Value of each slice on the chart. Multiple data points for the same group can be be aggregated using an [aggregation function](https://preview.docs.tenzir.com/375/375/reference/functions.md#aggregation).

Multiple `y` values and their labels can be specified by using the record syntax: `{name: value, ...}`.

For example, `y = {"Avg. Load": mean(load)}` calculates the [`mean`](https://preview.docs.tenzir.com/375/375/reference/functions/mean.md) of the `load` field and labels it as `Avg. Load`.

### `group = any (optional)`

Optional expression to group the aggregations with.

## Examples

### Chart count of events imported for every unique schema

```tql
metrics "import"
where timestamp > now() - 1d
chart_pie label=schema, value=sum(events)
```

## See Also

* [`chart_area`](https://preview.docs.tenzir.com/375/375/reference/operators/chart_area.md)
* [`chart_bar`](https://preview.docs.tenzir.com/375/375/reference/operators/chart_bar.md)
* [`chart_line`](https://preview.docs.tenzir.com/375/375/reference/operators/chart_line.md)
* [Plot data with charts](https://preview.docs.tenzir.com/375/375/tutorials/plot-data-with-charts.md)