MatesCharts v0.6.0
All charts

Sankey

Sankey diagrams trace flow between nodes — energy budgets, user journeys, cost allocation. Each point is { from, to, weight }; node positions are computed automatically.

Module setup. Auto-loaded by the main mates-charts entry (Tier A). Bare-core users import the module explicitly.
import "highcharts/modules/sankey";

Usage

Create a chart atom with standard Highcharts options, then render Chart(chart) anywhere in a mates template. Every later chart.set(…) or chart.update(…) re-renders the chart — no imperative Highcharts code.

Quick start
import { html } from "mates";
import { Chart, chartAtom } from "mates-charts";

const chart = chartAtom({
    chart: {
        type: "sankey"
    },
    title: {
        text: "Revenue allocation"
    },
    credits: {
        enabled: false
    },
    colors: [
        "#00968c",
        "#06b6d4",
        "#d97706",
        "#7c3aed",
        "#dc2626",
        "#16a34a",
        "#0172ad",
        "#9333ea"
    ],
    legend: {
        enabled: false
    },
    plotOptions: {
        sankey: {
            dataLabels: {
                enabled: true,
                format: "{point.from} → {point.to}: {point.weight}"
            }
        }
    },
    series: [
        {
            type: "sankey",
            name: "Flow",
            data: [
                {
                    from: "Revenue",
                    to: "Product",
                    weight: 420
                },
                {
                    from: "Revenue",
                    to: "Marketing",
                    weight: 180
                },
                {
                    from: "Revenue",
                    to: "Operations",
                    weight: 150
                },
                {
                    from: "Product",
                    to: "Engineering",
                    weight: 280
                },
                {
                    from: "Product",
                    to: "Design",
                    weight: 140
                },
                {
                    from: "Marketing",
                    to: "Ads",
                    weight: 110
                },
                {
                    from: "Marketing",
                    to: "Content",
                    weight: 70
                }
            ]
        }
    ]
});

// render inside any mates template — give the wrapper a height:
export const MyChart = () =>
    html`<div style="height: 22rem">${Chart(chart)}</div>`;

Live examples

Created with Highcharts 12.5.0Revenue allocationRevenue → Product: 420​Revenue → Product: 420Revenue → Marketing: 180​Revenue → Marketing: 180Revenue → Operations: 150​Revenue → Operations: 150Product → Engineering: 280​Product → Engineering: 280Product → Design: 140​Product → Design: 140Marketing → Ads: 110​Marketing → Ads: 110Marketing → Content: 70​Marketing → Content: 70→ :​→ :→ :​→ :→ :​→ :→ :​→ :→ :​→ :→ :​→ :→ :​→ :→ :​→ :

Sources on the left, destinations on the right; link thickness = weight. Nodes inherit colours from links automatically.

TypeScript
import { html } from "mates";
import { Chart, chartAtom } from "mates-charts";

const chart = chartAtom({
    chart: {
        type: "sankey"
    },
    title: {
        text: "Revenue allocation"
    },
    credits: {
        enabled: false
    },
    colors: [
        "#00968c",
        "#06b6d4",
        "#d97706",
        "#7c3aed",
        "#dc2626",
        "#16a34a",
        "#0172ad",
        "#9333ea"
    ],
    legend: {
        enabled: false
    },
    plotOptions: {
        sankey: {
            dataLabels: {
                enabled: true,
                format: "{point.from} → {point.to}: {point.weight}"
            }
        }
    },
    series: [
        {
            type: "sankey",
            name: "Flow",
            data: [
                {
                    from: "Revenue",
                    to: "Product",
                    weight: 420
                },
                {
                    from: "Revenue",
                    to: "Marketing",
                    weight: 180
                },
                {
                    from: "Revenue",
                    to: "Operations",
                    weight: 150
                },
                {
                    from: "Product",
                    to: "Engineering",
                    weight: 280
                },
                {
                    from: "Product",
                    to: "Design",
                    weight: 140
                },
                {
                    from: "Marketing",
                    to: "Ads",
                    weight: 110
                },
                {
                    from: "Marketing",
                    to: "Content",
                    weight: 70
                }
            ]
        }
    ]
});

// render inside any mates template — give the wrapper a height:
export const MyChart = () =>
    html`<div style="height: 22rem">${Chart(chart)}</div>`;
Created with Highcharts 12.5.0Onboarding journeyhighcharts-5wubmrg-19​highcharts-5wubmrg-19highcharts-5wubmrg-20​highcharts-5wubmrg-20highcharts-5wubmrg-21​highcharts-5wubmrg-21highcharts-5wubmrg-22​highcharts-5wubmrg-22highcharts-5wubmrg-23​highcharts-5wubmrg-23highcharts-5wubmrg-24​highcharts-5wubmrg-24Visit​VisitSignup​SignupBounce​BounceActivated​ActivatedDormant​DormantPaid​PaidFree tier​Free tier
Multi-stage journey

Chains of from → to links create stages automatically; null-weight links keep drop-offs visible.

TypeScript
import { html } from "mates";
import { Chart, chartAtom } from "mates-charts";

const chart = chartAtom({
    chart: {
        type: "sankey"
    },
    title: {
        text: "Onboarding journey"
    },
    credits: {
        enabled: false
    },
    colors: [
        "#00968c",
        "#06b6d4",
        "#d97706",
        "#7c3aed",
        "#dc2626",
        "#16a34a",
        "#0172ad",
        "#9333ea"
    ],
    legend: {
        enabled: false
    },
    plotOptions: {
        sankey: {
            nodeAlignment: "left",
            dataLabels: {
                enabled: true,
                format: "{point.name}"
            }
        }
    },
    series: [
        {
            type: "sankey",
            name: "Journey",
            data: [
                {
                    from: "Visit",
                    to: "Signup",
                    weight: 1254
                },
                {
                    from: "Visit",
                    to: "Bounce",
                    weight: 8746
                },
                {
                    from: "Signup",
                    to: "Activated",
                    weight: 820
                },
                {
                    from: "Signup",
                    to: "Dormant",
                    weight: 434
                },
                {
                    from: "Activated",
                    to: "Paid",
                    weight: 336
                },
                {
                    from: "Activated",
                    to: "Free tier",
                    weight: 484
                }
            ]
        }
    ]
});

// render inside any mates template — give the wrapper a height:
export const MyChart = () =>
    html`<div style="height: 22rem">${Chart(chart)}</div>`;

Options reference

mates-charts passes options straight through to Highcharts — these are the keys that matter for sankey charts. See the full Highcharts API for everything else.

Option Type Default Description
chart.type "sankey" — Registered by mates-charts (Tier A) or highcharts/modules/sankey.
series[].data { from, to, weight }[] — Links; nodes materialise from the from/to names.
plotOptions.sankey.nodeAlignment "left" | "right" | "center" | "justify" "justify" Node column alignment.
plotOptions.sankey.nodeWidth / nodePadding number — Node box sizing.
series[].nodes[] { id, color, offset }[] — Optional per-node overrides — colours, vertical offsets.
plotOptions.sankey.dataLabels DataLabelsOptions — Label links and/or nodes — {point.from}, {point.to}, {point.weight}.