# Drill Down (Sankey example)

> WestCoast Charts 1.1.5, release, public Core release, on npm. HTML: https://westcoast-charts.com/gallery/sankey/drill-down/ · Index for agents: https://westcoast-charts.com/llms.txt

plotOptions.sankey.drilldown: click a region to open its countries (EMEA → Germany goes one level deeper, loaded on demand); the breadcrumb, Escape or Up go back.

- Chart type: `sankey` (Sankey)
- Collection: Sankey · Sankey
- Raw configuration: https://westcoast-charts.com/gallery-src/sankey/drill-down.js
- Standalone example: https://westcoast-charts.com/embed/samples/wcc/gallery/premium/sankey/drill-down.html

## Setup

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

WestCoastCharts.use(types).use(premium)
const WestCoastChartsPremium = premium
WestCoastCharts.setLicenseKey(LICENCE_KEY) // paid production licence; localhost evaluation needs no key
```

## Options

```js
const options = {
  chart: {
    height: 420,
    toolbar: {
      show: false
    },
    type: "sankey",
    events: {
      drilldown: (e, ctx, o) => log('drilldown ' + o.name + ' (depth ' + o.depth + ')'),
      drillup: (e, ctx, o) => log('drillup to ' + o.label)
    }
  },
  series: [
    {
      data: [
        ["EMEA", "Revenue", 420],
        ["Americas", "Revenue", 510],
        ["APAC", "Revenue", 260],
        ["Revenue", "Profit", 380],
        ["Revenue", "Costs", 810]
      ]
    }
  ],
  plotOptions: {
    sankey: {
      drilldown: {
        rootLabel: "All regions",
        nodes: {
          EMEA: {
            label: "EMEA",
            data: [
              ["Germany", "EMEA", 160],
              ["France", "EMEA", 110],
              ["UK", "EMEA", 95],
              ["Nordics", "EMEA", 55],
              ["EMEA", "Revenue", 420]
            ],
            nodes: [
              {
                id: "EMEA",
                color: "#64748b"
              }
            ]
          },
          Americas: {
            label: "Americas",
            data: [
              ["USA", "Americas", 380],
              ["Canada", "Americas", 70],
              ["Brazil", "Americas", 60],
              ["Americas", "Revenue", 510]
            ],
            nodes: [
              {
                id: "Americas",
                color: "#64748b"
              }
            ]
          },
          APAC: {
            label: "APAC",
            data: [
              ["Japan", "APAC", 120],
              ["Australia", "APAC", 80],
              ["Singapore", "APAC", 60],
              ["APAC", "Revenue", 260]
            ],
            nodes: [
              {
                id: "APAC",
                color: "#64748b"
              }
            ]
          }
        },
        drillable: ["Germany"],
        load: (n) => new Promise((res) => setTimeout(() => res({ label: n.name, data: [['Hardware', n.name, 70], ['Software', n.name, 60], ['Services', n.name, 30], [n.name, 'EMEA', 160]] }), 500))
      }
    }
  },
  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 sankey-drill-down.json --out sankey-drill-down.svg --with-table` (save the options above as JSON first)
