Sankey diagram
A Sankey diagram shows how a total flows from sources to targets, such as channels to outcomes or a budget to cost types. Ribbon width is the size of the flow.
- React
import { SankeyChart } from 'boardplot/react/sankey';- Reference
- Data, options and sizing
- Use for
- Channel to landing page to purchase · Budget to departments · Customers moving between segments month to month
Budget to departments to cost types
Sankey of a $96m operating budget through five departments into five cost types; Engineering takes $41m and staff costs take $62m.
budget-departments
JSON spec
This spec includes the theme shown and the options you selected.
Changed from the fixture: options.size from the report frame to the width of the site frame.
{
"type": "sankey",
"data": {
"links": [
{
"source": "budget",
"target": "engineering",
"value": 41
},
{
"source": "budget",
"target": "sales",
"value": 23
},
{
"source": "budget",
"target": "marketing",
"value": 14
},
{
"source": "budget",
"target": "operations",
"value": 12
},
{
"source": "budget",
"target": "admin",
"value": 6
},
{
"source": "engineering",
"target": "staff",
"value": 31
},
{
"source": "engineering",
"target": "cloud",
"value": 10
},
{
"source": "sales",
"target": "staff",
"value": 17
},
{
"source": "sales",
"target": "travel",
"value": 6
},
{
"source": "marketing",
"target": "media",
"value": 11
},
{
"source": "marketing",
"target": "staff",
"value": 3
},
{
"source": "operations",
"target": "staff",
"value": 7
},
{
"source": "operations",
"target": "facilities",
"value": 5
},
{
"source": "admin",
"target": "staff",
"value": 4
},
{
"source": "admin",
"target": "facilities",
"value": 2
}
],
"nodes": [
{
"id": "budget",
"label": "Operating budget"
},
{
"id": "engineering",
"label": "Engineering"
},
{
"id": "sales",
"label": "Sales"
},
{
"id": "marketing",
"label": "Marketing"
},
{
"id": "operations",
"label": "Operations"
},
{
"id": "admin",
"label": "Administration"
},
{
"id": "staff",
"label": "Staff"
},
{
"id": "cloud",
"label": "Cloud services"
},
{
"id": "travel",
"label": "Travel"
},
{
"id": "media",
"label": "Paid media"
},
{
"id": "facilities",
"label": "Facilities"
}
]
},
"options": {
"title": "Staff costs take two thirds of the operating budget",
"source": "Illustrative data",
"unit": "$m",
"linkColor": "target",
"nodeValue": "value-share",
"size": {
"width": 1000
}
}
}Channel to landing page to outcome
Sankey of 1,376k visits from channels through three landing pages to two outcomes: 365k end in a purchase and 1,011k leave the site. Two small channels fold into Others.
channel-journeys
JSON spec
This spec includes the theme shown and the options you selected.
{
"type": "sankey",
"data": {
"links": [
{
"source": "search",
"target": "product",
"value": 420
},
{
"source": "search",
"target": "home",
"value": 180
},
{
"source": "search",
"target": "offer",
"value": 60
},
{
"source": "social",
"target": "home",
"value": 260
},
{
"source": "social",
"target": "offer",
"value": 140
},
{
"source": "email",
"target": "product",
"value": 140
},
{
"source": "email",
"target": "offer",
"value": 90
},
{
"source": "partners",
"target": "product",
"value": 70
},
{
"source": "display",
"target": "home",
"value": 9
},
{
"source": "affiliates",
"target": "offer",
"value": 7
},
{
"source": "product",
"target": "purchase",
"value": 205
},
{
"source": "product",
"target": "exit",
"value": 425
},
{
"source": "home",
"target": "purchase",
"value": 64
},
{
"source": "home",
"target": "exit",
"value": 385
},
{
"source": "offer",
"target": "purchase",
"value": 96
},
{
"source": "offer",
"target": "exit",
"value": 201
}
],
"nodes": [
{
"id": "search",
"label": "Search"
},
{
"id": "social",
"label": "Social"
},
{
"id": "email",
"label": "Email"
},
{
"id": "partners",
"label": "Partners"
},
{
"id": "display",
"label": "Display"
},
{
"id": "affiliates",
"label": "Affiliates"
},
{
"id": "product",
"label": "Product page"
},
{
"id": "home",
"label": "Home page"
},
{
"id": "offer",
"label": "Offer page"
},
{
"id": "purchase",
"label": "Purchase"
},
{
"id": "exit",
"label": "Left the site"
}
],
"stages": [
{
"id": "channel",
"label": "Channel"
},
{
"id": "page",
"label": "Landing page"
},
{
"id": "outcome",
"label": "Outcome"
}
]
},
"options": {
"title": "Search brings the most visits that end in a purchase",
"source": "Illustrative data",
"unit": "k visits",
"highlight": "purchase",
"notes": {
"show": [
"note",
"disclosure"
]
},
"size": {
"width": 960,
"height": 560
}
}
}Customers moving between segments
Sankey of customers in the Gold, Silver, Bronze and Lapsed segments from January to April; most stay in their segment each month.
segment-migration
JSON spec
This spec includes the theme shown and the options you selected.
Changed from the fixture: data.nodes; options.size from the report frame to the width of the site frame.
{
"type": "sankey",
"data": {
"links": [
{
"source": "gold",
"sourceStage": "jan",
"target": "gold",
"targetStage": "feb",
"value": 820
},
{
"source": "gold",
"sourceStage": "jan",
"target": "silver",
"targetStage": "feb",
"value": 90
},
{
"source": "gold",
"sourceStage": "jan",
"target": "bronze",
"targetStage": "feb",
"value": 20
},
{
"source": "gold",
"sourceStage": "jan",
"target": "lapsed",
"targetStage": "feb",
"value": 10
},
{
"source": "silver",
"sourceStage": "jan",
"target": "gold",
"targetStage": "feb",
"value": 70
},
{
"source": "silver",
"sourceStage": "jan",
"target": "silver",
"targetStage": "feb",
"value": 1240
},
{
"source": "silver",
"sourceStage": "jan",
"target": "bronze",
"targetStage": "feb",
"value": 150
},
{
"source": "silver",
"sourceStage": "jan",
"target": "lapsed",
"targetStage": "feb",
"value": 60
},
{
"source": "bronze",
"sourceStage": "jan",
"target": "gold",
"targetStage": "feb",
"value": 15
},
{
"source": "bronze",
"sourceStage": "jan",
"target": "silver",
"targetStage": "feb",
"value": 110
},
{
"source": "bronze",
"sourceStage": "jan",
"target": "bronze",
"targetStage": "feb",
"value": 1580
},
{
"source": "bronze",
"sourceStage": "jan",
"target": "lapsed",
"targetStage": "feb",
"value": 240
},
{
"source": "lapsed",
"sourceStage": "jan",
"target": "gold",
"targetStage": "feb",
"value": 5
},
{
"source": "lapsed",
"sourceStage": "jan",
"target": "silver",
"targetStage": "feb",
"value": 30
},
{
"source": "lapsed",
"sourceStage": "jan",
"target": "bronze",
"targetStage": "feb",
"value": 120
},
{
"source": "lapsed",
"sourceStage": "jan",
"target": "lapsed",
"targetStage": "feb",
"value": 2100
},
{
"source": "gold",
"sourceStage": "feb",
"target": "gold",
"targetStage": "mar",
"value": 790
},
{
"source": "gold",
"sourceStage": "feb",
"target": "silver",
"targetStage": "mar",
"value": 100
},
{
"source": "gold",
"sourceStage": "feb",
"target": "bronze",
"targetStage": "mar",
"value": 15
},
{
"source": "gold",
"sourceStage": "feb",
"target": "lapsed",
"targetStage": "mar",
"value": 5
},
{
"source": "silver",
"sourceStage": "feb",
"target": "gold",
"targetStage": "mar",
"value": 95
},
{
"source": "silver",
"sourceStage": "feb",
"target": "silver",
"targetStage": "mar",
"value": 1210
},
{
"source": "silver",
"sourceStage": "feb",
"target": "bronze",
"targetStage": "mar",
"value": 140
},
{
"source": "silver",
"sourceStage": "feb",
"target": "lapsed",
"targetStage": "mar",
"value": 25
},
{
"source": "bronze",
"sourceStage": "feb",
"target": "gold",
"targetStage": "mar",
"value": 20
},
{
"source": "bronze",
"sourceStage": "feb",
"target": "silver",
"targetStage": "mar",
"value": 140
},
{
"source": "bronze",
"sourceStage": "feb",
"target": "bronze",
"targetStage": "mar",
"value": 1440
},
{
"source": "bronze",
"sourceStage": "feb",
"target": "lapsed",
"targetStage": "mar",
"value": 270
},
{
"source": "lapsed",
"sourceStage": "feb",
"target": "gold",
"targetStage": "mar",
"value": 10
},
{
"source": "lapsed",
"sourceStage": "feb",
"target": "silver",
"targetStage": "mar",
"value": 60
},
{
"source": "lapsed",
"sourceStage": "feb",
"target": "bronze",
"targetStage": "mar",
"value": 155
},
{
"source": "lapsed",
"sourceStage": "feb",
"target": "lapsed",
"targetStage": "mar",
"value": 2185
},
{
"source": "gold",
"sourceStage": "mar",
"target": "gold",
"targetStage": "apr",
"value": 815
},
{
"source": "gold",
"sourceStage": "mar",
"target": "silver",
"targetStage": "apr",
"value": 80
},
{
"source": "gold",
"sourceStage": "mar",
"target": "bronze",
"targetStage": "apr",
"value": 15
},
{
"source": "gold",
"sourceStage": "mar",
"target": "lapsed",
"targetStage": "apr",
"value": 5
},
{
"source": "silver",
"sourceStage": "mar",
"target": "gold",
"targetStage": "apr",
"value": 90
},
{
"source": "silver",
"sourceStage": "mar",
"target": "silver",
"targetStage": "apr",
"value": 1250
},
{
"source": "silver",
"sourceStage": "mar",
"target": "bronze",
"targetStage": "apr",
"value": 140
},
{
"source": "silver",
"sourceStage": "mar",
"target": "lapsed",
"targetStage": "apr",
"value": 30
},
{
"source": "bronze",
"sourceStage": "mar",
"target": "gold",
"targetStage": "apr",
"value": 25
},
{
"source": "bronze",
"sourceStage": "mar",
"target": "silver",
"targetStage": "apr",
"value": 130
},
{
"source": "bronze",
"sourceStage": "mar",
"target": "bronze",
"targetStage": "apr",
"value": 1470
},
{
"source": "bronze",
"sourceStage": "mar",
"target": "lapsed",
"targetStage": "apr",
"value": 125
},
{
"source": "lapsed",
"sourceStage": "mar",
"target": "gold",
"targetStage": "apr",
"value": 5
},
{
"source": "lapsed",
"sourceStage": "mar",
"target": "silver",
"targetStage": "apr",
"value": 45
},
{
"source": "lapsed",
"sourceStage": "mar",
"target": "bronze",
"targetStage": "apr",
"value": 210
},
{
"source": "lapsed",
"sourceStage": "mar",
"target": "lapsed",
"targetStage": "apr",
"value": 2225
}
],
"nodes": [
{
"id": "gold",
"label": "Gold",
"colorRole": "highlight"
},
{
"id": "silver",
"label": "Silver"
},
{
"id": "bronze",
"label": "Bronze"
},
{
"id": "lapsed",
"label": "Lapsed"
}
],
"stages": [
{
"id": "jan",
"label": "January"
},
{
"id": "feb",
"label": "February"
},
{
"id": "mar",
"label": "March"
},
{
"id": "apr",
"label": "April"
}
]
},
"options": {
"title": "Most customers stay in their segment from month to month",
"source": "Illustrative data",
"unit": "customers",
"linkColor": "source",
"size": {
"width": 1000
}
}
}Minimal spec
Save this spec as sankey.json and run the command.
{
"type": "sankey",
"data": {
"links": [
{ "source": "search", "target": "product", "value": 420 },
{ "source": "search", "target": "home", "value": 180 },
{ "source": "social", "target": "home", "value": 260 },
{ "source": "email", "target": "product", "value": 140 },
{ "source": "product", "target": "purchase", "value": 210 },
{ "source": "home", "target": "purchase", "value": 90 }
],
"nodes": [
{ "id": "search", "label": "Search" },
{ "id": "social", "label": "Social" },
{ "id": "email", "label": "Email" },
{ "id": "product", "label": "Product page" },
{ "id": "home", "label": "Home page" },
{ "id": "purchase", "label": "Purchase" }
],
"stages": [
{ "id": "channel", "label": "Channel" },
{ "id": "page", "label": "Landing page" },
{ "id": "outcome", "label": "Outcome" }
]
},
"options": {
"title": "Search brings most visits that end in a purchase",
"unit": "k visits",
"source": "Illustrative data"
}
}npx boardplot render sankey.json --out sankey.svg