---
title: "Donut Chart Image API — Donut charts via API | Imejis"
description: "Generate donut chart images with a configurable hole for a centered metric — slice data updated on every API call. Create donut chart images free."
url: "https://www.imejis.io/components/pie/donut"
---

# Donut Chart Image API — Donut charts via API | Imejis

A pie with a hole — leaves room for a centered metric.

## Use cases

- KPI share visuals with a number in the middle
- Storage or budget usage breakdowns
- Modern dashboard-style report images

## 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": 250,
        "y": 60
      },
      "rotation": 0,
      "size": {
        "width": 300,
        "height": 300
      },
      "dynamic": true,
      "properties": {
        "variant": "donut",
        "data": [
          40,
          30,
          20,
          10
        ],
        "labels": [
          "North",
          "South",
          "East",
          "West"
        ],
        "colors": [],
        "showValues": true,
        "labelType": "percent",
        "showLegend": true,
        "legendPosition": "bottom",
        "opacity": 1,
        "innerRadius": 0.6
      }
    }
  ]
}
```

## Examples

### Storage usage by file type

Photos, video, documents and other as a donut for a usage report email.

API overrides that reproduce this example:

```json
{
  "share.variant": "donut",
  "share.innerRadius": 0.6,
  "share.data": [
    48,
    27,
    15,
    10
  ],
  "share.labels": [
    "Photos",
    "Video",
    "Docs",
    "Other"
  ],
  "share.colors": [
    "#6366F1",
    "#0EA5E9",
    "#F59E0B",
    "#94A3B8"
  ]
}
```

### Portfolio allocation

An investment mix across four asset classes with a roomy center hole.

API overrides that reproduce this example:

```json
{
  "share.variant": "donut",
  "share.innerRadius": 0.65,
  "share.data": [
    55,
    25,
    12,
    8
  ],
  "share.labels": [
    "Stocks",
    "Bonds",
    "Cash",
    "Crypto"
  ],
  "share.colors": [
    "#10B981",
    "#6366F1",
    "#94A3B8",
    "#F59E0B"
  ]
}
```

## 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
- [Raw values](https://www.imejis.io/components/pie/raw-values.md) — Slice labels show the underlying numbers instead of percentages.
- [Legend](https://www.imejis.io/components/pie/legend.md) — Slice names in a side legend — for labels that will not fit on the pie.
