# Donut drilldown (Pie example)

> WestCoast Charts 1.1.5, release, public Core release, on npm. HTML: https://westcoast-charts.com/gallery/pie/donut-with-drilldown/ · Index for agents: https://westcoast-charts.com/llms.txt

Click a slice to see its breakdown; the breadcrumb goes back.

- Chart type: `donut` (Donut)
- Collection: Pie · Pie & donut
- Raw configuration: https://westcoast-charts.com/gallery-src/pie/donut-with-drilldown.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/pie/donut-with-drilldown.html

## Setup

```js
import WestCoastCharts from 'west-coast-charts'
import types from 'west-coast-charts/types'
import drilldown from 'west-coast-charts/features/drilldown'

WestCoastCharts.use(types).use(drilldown)
```

## Options

```js
const options = {
  chart: {
    height: 380,
    fontFamily: "Inter, Geist, \"IBM Plex Sans\", system-ui, sans-serif",
    type: "donut",
    toolbar: {
      show: false
    }
  },
  series: [
    {
      name: "Revenue",
      data: [
        {
          x: "Hardware",
          y: 48,
          drilldown: "Hardware"
        },
        {
          x: "Software",
          y: 32,
          drilldown: "Software"
        },
        {
          x: "Services",
          y: 20,
          drilldown: "Services"
        }
      ]
    }
  ],
  drilldown: {
    enabled: true,
    series: [
      {
        id: "Hardware",
        name: "Hardware revenue (M€)",
        data: [
          {
            x: "Laptops",
            y: 22
          },
          {
            x: "Phones",
            y: 16
          },
          {
            x: "Monitors",
            y: 10
          }
        ]
      },
      {
        id: "Software",
        name: "Software revenue (M€)",
        data: [
          {
            x: "Licences",
            y: 18
          },
          {
            x: "SaaS",
            y: 9
          },
          {
            x: "Add-ons",
            y: 5
          }
        ]
      },
      {
        id: "Services",
        name: "Services revenue (M€)",
        data: [
          {
            x: "Support",
            y: 12
          },
          {
            x: "Training",
            y: 8
          }
        ]
      }
    ]
  },
  legend: {
    position: "bottom"
  },
  title: {
    text: "Revenue (M€), click a slice"
  },
  theme: {
    mode: "light",
    preset: "coastal"
  }
}

const chart = new WestCoastCharts(document.querySelector('#chart'), options)
await chart.render()
```

## Verify

- Text check (Library 1.1.5): load `west-coast-charts/agent/describe` and call `chart.describe({ format: "json" })` for the actual drawn state. The live reader is on this example’s HTML page.
- Command line (Public agent tools 0.2.3, tested with Library 1.1.5; available from the versioned GitHub release and npm, https://westcoast-charts.com/docs/cli/index.md): `wcc chart export pie-donut-with-drilldown.json --out pie-donut-with-drilldown.svg --with-table` (save the options above as JSON first)
