# Pie Chart

The **Pie Chart** panel displays how a metric’s values are distributed across categories. Use it to visualize proportions, compare categories, and highlight dominant contributors.

#### Add a Pie Chart panel

1. Open the dashboard where you want the panel.

2. Click **Add Panel**.

3. In **Choose Visualization**, select **Pie Chart**.

4. Build your query in **Graph your data** to return a metric and grouping field.

5. Enter a descriptive **Title**.

6. Click **Save** to add the panel.

#### Build queries (Graph your data)

The **Graph your data** section defines which metrics are displayed and how they are processed before visualization. These steps apply to most panel types in Kloudfuse.

1. Click **Add Query** to create a new query. Repeat to add multiple queries.

2. Click **Select a metric** to choose the metric name you want to query.

3. Use **From** to select the metric source or namespace.

4. Click **Add Label** to filter results by label values (for example: `pod=web`, `env=prod`).

5. Select an **Aggregation** (for example: `min`, `max`, `sum`, `avg`) to reduce raw samples to one value per time interval.

6. Use the **Select** dropdown (if available) to set the aggregation interval (for example: `1m`, `5m`).

7. Click **Add Functions** to apply transformations to your data.

Common examples:
\* `rate()` — Convert counters to rates.
\* `derivative()` — Show the rate of change.
\* `moving_avg()` — Smooth short-term fluctuations.
\* `scale()` — Multiply values by a constant.

|     |     |
| --- | --- |
|  | Query order determines formula identifiers: the first query = `a`, second = `b`, etc.<br>Assign aliases to queries for more readable formulas. |

#### Add formulas

Use formulas to create new series from existing queries.

1. Click **Add Formula** in **Graph your data**.

2. Reference queries by their letter (`a`, `b`, …) or alias.

3. Enter your expression and click **Apply**.

Example — double a series:

```
2*a
```

Example — percentage change between two queries:

```
((a - b) / b) * 100
```

|     |     |
| --- | --- |
|  | - Use parentheses to control precedence: `2*(a + b)` vs. `2*a + b`.<br>  <br>- If queries return different intervals, the formula engine aligns or interpolates values.<br>  <br>- Add a **Label** so the formula appears meaningfully in the legend. |

### Pie Chart–specific settings

Once your query returns grouped data:

- **Group by** — Choose a field to define the pie slices (for example: `host`, `service`, `region`).

- **Aggregation** — Select a method to calculate slice values (for example: `sum`, `avg`, `max`, `min`).

- **Slice labels** — Display category names, percentages, values, or a combination.

- **Color palette** — Assign consistent colors to categories for easier recognition.

- **Legend placement** — Show legends inside or outside the chart.

- **Donut mode** — Optionally display as a donut chart by enabling the center hole.

### Best practices

- Group by dimensions that meaningfully segment your data.

- Limit the number of slices to avoid clutter (merge small slices into “Other” if available).

- Use a consistent color palette across related dashboards for familiarity.
