---
title: "Pie Chart with Legend API — Labeled slice charts | Imejis"
description: "Name every slice in a side legend when labels are too long to fit on the pie — perfect for OG images, with data set per API call. Try Imejis free."
url: "https://www.imejis.io/components/pie/legend"
---

# Pie Chart with Legend API — Labeled slice charts | Imejis

Slice names in a side legend — for labels that will not fit on the pie.

## Use cases

- OG images where slice labels would overflow
- Reports with longer category names
- Small charts that need to stay readable

## Properties

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `variant` | `'pie' \| 'donut'` | `"pie"` | Full pie or donut with a hole. |
| `data` | `number[]` | `[]` | Slice values. |
| `labels` | `string[]` | `[]` | Slice names. |
| `colors` | `color[]` | `[]` | Slice color palette (falls back to built-in palette). |
| `innerRadius` | `number` (min 0, max 1) | `0.6` | Donut hole radius as a fraction of the pie radius. |
| `showValues` | `boolean` | `true` | Print a label on each slice. |
| `labelType` | `'percent' \| 'value'` | `"percent"` | Whether slice labels show percentages or raw values. |
| `showLegend` | `boolean` | `true` | Show the slice legend. |
| `legendPosition` | `'top' \| 'right' \| 'bottom'` | `"bottom"` | Where the legend is placed. |
| `textColor` | `color` | `"#52514e"` | Color of labels and legend text. |
| `opacity` | `number` | `1` | Overall component opacity from 0 (transparent) to 1 (opaque). |
| `borderWidth` | `number` | `0` | Border thickness in pixels around the component. |
| `borderColor` | `color` | `"transparent"` | Border color (any CSS color). |
| `borderStyle` | `'solid' \| 'dashed' \| 'dotted' \| 'double' \| 'none'` | `"solid"` | Border line style. |
| `borderRadius` | `number` | `0` | Corner radius in pixels. |
| `boxShadow` | `string` | — | CSS box-shadow applied to the component, e.g. "0 4px 6px rgba(0,0,0,0.1)". |

## Design JSON (this variant)

```json
{
  "title": "Pie chart sample",
  "description": "A dynamic pie chart",
  "dimensions": {
    "width": 800,
    "height": 420
  },
  "background": {
    "color": "#ffffff"
  },
  "components": [
    {
      "id": "sample-pie",
      "key": "share",
      "type": "pie",
      "position": {
        "x": 190,
        "y": 70
      },
      "rotation": 0,
      "size": {
        "width": 420,
        "height": 280
      },
      "dynamic": true,
      "properties": {
        "variant": "pie",
        "data": [
          40,
          30,
          20,
          10
        ],
        "labels": [
          "North",
          "South",
          "East",
          "West"
        ],
        "colors": [],
        "showValues": false,
        "labelType": "percent",
        "showLegend": true,
        "legendPosition": "right",
        "opacity": 1
      }
    }
  ]
}
```

## Examples

### Acquisition channels OG image

Traffic share with channel names in a right-hand legend instead of on the slices.

API overrides that reproduce this example:

```json
{
  "share.showValues": false,
  "share.showLegend": true,
  "share.legendPosition": "right",
  "share.data": [
    52,
    23,
    15,
    10
  ],
  "share.labels": [
    "Organic",
    "Paid search",
    "Referral",
    "Email"
  ],
  "share.colors": [
    "#6366F1",
    "#F59E0B",
    "#0EA5E9",
    "#10B981"
  ]
}
```

### Ad spend by platform

Quarterly ad budget share across four platforms on a dark canvas.

API overrides that reproduce this example:

```json
{
  "share.showValues": false,
  "share.showLegend": true,
  "share.legendPosition": "right",
  "share.data": [
    45,
    30,
    15,
    10
  ],
  "share.labels": [
    "Google Ads",
    "Meta",
    "LinkedIn",
    "TikTok"
  ],
  "share.colors": [
    "#0EA5E9",
    "#6366F1",
    "#10B981",
    "#F472B6"
  ],
  "share.textColor": "#E2E8F0"
}
```

## API overrides

Update slice values with '<key>.data' (or just '<key>') and names with '<key>.labels'; variant and colors are overridable too.

Flat override payload (`key.property` addressing) with the sample design's current values — send only the keys you want to change:

```json
{
  "share.variant": "pie",
  "share.data": [
    40,
    30,
    20,
    10
  ],
  "share.labels": [
    "North",
    "South",
    "East",
    "West"
  ],
  "share.colors": [],
  "share.showValues": true,
  "share.labelType": "percent",
  "share.showLegend": true,
  "share.legendPosition": "bottom",
  "share.opacity": 1
}
```

```bash
curl --location 'https://render.imejis.io/v1/{{YOUR_DESIGN_ID}}' \
--header 'dma-api-key: {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data '{
    "share.variant": "pie",
    "share.data": [
        40,
        30,
        20,
        10
    ],
    "share.labels": [
        "North",
        "South",
        "East",
        "West"
    ],
    "share.colors": [],
    "share.showValues": true,
    "share.labelType": "percent",
    "share.showLegend": true,
    "share.legendPosition": "bottom",
    "share.opacity": 1
}'
```

`{{YOUR_DESIGN_ID}}` and `{{YOUR_API_KEY}}` are placeholders: first create
the design in your account (paste the sample design JSON above into the
editor at https://app.imejis.io, or create it programmatically via the
imejis MCP server's `create_design` + `update_design` tools), then render
it with the design's id and one of your API keys.

Agents: the MCP server at https://api.imejis.io/api/mcp exposes this same
catalog as structured data via the `list_component_types` tool (property
kinds, allowed values, bounds, ready-to-use sample designs).

## Related

- [Pie Chart component](https://www.imejis.io/components/pie.md) — full reference and FAQs
- [Donut](https://www.imejis.io/components/pie/donut.md) — A pie with a hole — leaves room for a centered metric.
- [Raw values](https://www.imejis.io/components/pie/raw-values.md) — Slice labels show the underlying numbers instead of percentages.
