Drill Down
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.
Open the chart without page chrome ↗Drawing width at least 900 px. Scroll within the chart on smaller screens.
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)
chart.render()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
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() Waiting for the chart.
Open Data & agent view to read this chart through chart.describe().
Read from the running library through its optional agent/describe module. Text, table and JSON share the same snapshot. Demo data only.
$ wcc chart export sankey-drill-down.json --out sankey-drill-down.svg --with-table Public agent tools 0.2.3, tested with Library 1.1.5; available from the versioned GitHub release and npm. Save a JSON spec first and check the loaded runtime and supported modules before rendering. Command reference
Loading /gallery/sankey/drill-down/index.md … This example uses Premium modules. Compare licences · Embedding in a distributed product?