Skip to content

Sankey Chart

The Sankey chart draws weighted flows between nodes. Each row is an edge: a source, a target, and a numeric value for the link thickness. Multi-hop paths are built by stacking edge rows that share intermediate node names — one chart, many hops.

Use Sankey when your data is already an edge list (funnels, pipelines, conversion paths, energy balances) rather than a categorical matrix. Sankey is opt-in: run vizb sankey or pass -c sankey; it is not in the default bar,line,pie bundle.

Every edge has the same three roles, in this order:

Order Role Vizb field Example column (sankey-flows.csv)
1 source x source
2 target y target
3+ value (link weight) measure / stats value, optional cost, …
Extra Role
ZAxis Ignored if provided — no 3D; weights still aggregate per (source, target)
Name (n) Named chart panels (existing 4D behavior) — one Sankey per unique name

Group and solo --select use that same order. Column names come from your file; roles are always source → target → value.

Sample multi-hop funnel (optional name panels + a second measure cost). Use Copy CSV, save as sankey-flows.csv, then run a command below. A clone of the repo also has examples/csv/sankey-flows.csv.

sankey-flows.csv
namesourcetargetvaluecost
webVisitLanding500012
webLandingSignup12008
webLandingExit38002
webSignupTrial80015
webSignupNewsletter4005
webTrialPaid32025
webTrialChurn4803
appInstallOnboard300010
appOnboardActive180018
appOnboardDormant12004
appActiveSubscribe90030
appActiveFree9006
appSubscribeRenew60022
appSubscribeCancel3005

Group: list source then target under -g; -p x,y assigns those roles:

Terminal window
vizb sankey sankey-flows.csv -g source,target -p x,y -o out.html

Solo --select: exactly 3 columns — source, target, value (no -g):

Terminal window
vizb sankey sankey-flows.csv --select source,target,value -o out.html
Sankey chart of multi-hop flows with weighted links between source and target nodes

x = source, y = target, measure = flow weight. Each unique node name appears once; every row becomes (or merges into) a link.

Approach Flags (same column order) Notes
Group -g source,target -p x,y source/target as group axes; remaining numeric columns become measures
Solo --select --select source,target,value No -g; exactly 3 columns per flag (source, target, value)
Terminal window
# Group path (columns source → target)
vizb sankey sankey-flows.csv -g source,target -p x,y -o out.html
# Solo --select path (exactly 3 columns: source, target, value)
vizb sankey sankey-flows.csv --select source,target,value -o out.html

Another measure → another --select with the same source/target (stat tabs):

Terminal window
vizb sankey sankey-flows.csv --select source,target,value --select source,target,cost -o out.html

Solo --select for Sankey requires exactly 3 columns per flag (not 1, 2, or 4+). Extra measures use a second --select (same pattern as scatter multi-stat, but 3 cols each). The first two columns are always treated as node names (even if they look numeric).

Duplicate (source, target) pairs are summed into a single link. Multi-hop flows are just multiple edge rows that share intermediate node labels (for example Visit → Landing → Signup → Trial → Paid).

Pass n in the group pattern to split independent edge sets into separate chart panels — same 4D behavior as other chart types.

Terminal window
vizb sankey sankey-flows.csv -g name,source,target -p n,x,y -o out.html

If you include z in the pattern, Sankey still runs: there is no 3D scene and no layout use of z. Flow weights continue to sum per (source, target). Prefer -p x,y (or n,x,y) for clarity.

Terminal window
# Works, but z does not change layout — links still aggregate by source/target
vizb sankey data.csv -g source,target,channel -p x,y,z -o out.html

When the dataset has more than one numeric measure (for example value and cost), vizb keeps the usual stat tabs: one measure is active at a time, and each tab shows a single Sankey for that measure. With group active, --select can still pick which numeric columns become measures (stat pick), same as other charts.

Terminal window
# Two numeric columns → switch measures via stat tabs in the UI
vizb sankey sankey-flows.csv -g source,target -p x,y -o out.html
# Optional: keep only one measure under group
vizb sankey sankey-flows.csv -g source,target -p x,y --select value -o out.html

Sankey v1 supports sort, labels, and swap only — no log scale and no 3D controls.

Setting CLI flag UI toggle Notes
Sort --sort asc|desc Sort control Orders nodes / flows
Labels --show-labels Show labels Node names are always shown. --show-labels adds the same link values as the tooltip.
Swap --swap yx Axis switcher Swaps source and target (x ↔ y)
Terminal window
# Labels + descending sort on the sankey subcommand
vizb sankey sankey-flows.csv -g source,target -p x,y -l --sort desc -o out.html
# Root command: opt-in renderer only
vizb sankey-flows.csv -g source,target -p x,y -c sankey -o out.html
Terminal window
# Subcommand — single chart, flags limited to what Sankey supports
vizb sankey data.csv -g source,target -p x,y -o out.html
# Root — must opt in with -c; can combine with other renderers
vizb data.csv -g source,target -p x,y -c sankey -o out.html
vizb data.csv -g source,target -p x,y -c bar,sankey -o out.html
  • -p aliases on the vizb sankey subcommand only: source/target or s/t → still map to x / y internally; root -p vocabulary remains n / x / y / z.