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';
Use for
Channel to landing page to purchase · Budget to departments · Customers moving between segments month to month
Not for
Flows that loop back without stages (refused as a cycle; give links sourceStage and targetStage), or parts of one total (use treemap or bar). Pairwise rows do not say which channel a purchase came from once flows merge at a page: for that, build path-qualified nodes from journey data.

Budget to departments to cost types

Sankey of 15 flows between 11 nodes in 3 columns, total 96. Largest flows: Operating budget to Engineering 41; Engineering to Staff 31; Operating budget to Sales 23. Staff costs take two thirds of the operating budget $m Source: Illustrative data Operating budget 96 (100%) Staff 62 (65%) Engineering 41 (43%) Sales 23 (24%) Marketing 14 (15%) Operations 12 (13%) Paid media 11 (11%) Cloud services 10 (10%) Facilities 7 (7%) Administration 6 (6%) Travel 6 (6%) 31 17 7 5 4

Sankey of a $96m operating budget through five departments into five cost types; Engineering takes $41m and staff costs take $62m.

Download SVG Fixture IDbudget-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 16 flows between 10 nodes in 3 columns, total 1,376. Largest flows: Product page to Left the site 425; Search to Product page 420; Home page to Left the site 385. Search brings the most visits that end in a purchase k visits Source: Illustrative data Others (Channel): Display 9, Affiliates 7 Channel Outcome Landing page Left the site 1,011 Search 660 Product page 630 Home page 449 Social 400 Purchase 365 Offer page 297 Email 230 Partners 70 Others 16 425 420 385 260 205 201 180 140 140 96 90 70 64

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.

Download SVG Fixture IDchannel-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 48 flows between 16 nodes in 4 columns, total 6,660. Largest flows: Lapsed (March) to Lapsed (April) 2,225; Lapsed (February) to Lapsed (March) 2,185; Lapsed (January) to Lapsed (February) 2,100. Most customers stay in their segment from month to month Source: Illustrative data April February January March Lapsed 2,485 Lapsed 2,410 Lapsed 2,385 Lapsed 2,255 Bronze 1,945 Bronze 1,870 Bronze 1,835 Bronze 1,750 Silver 1,520 Silver 1,510 Silver 1,505 Silver 1,470 Gold 940 Gold 935 Gold 915 Gold 910 2,225 2,185 2,100 1,580 1,470 1,440 1,250 1,240 1,210 820 815 790 270

Sankey of customers in the Gold, Silver, Bronze and Lapsed segments from January to April; most stay in their segment each month.

Download SVG Fixture IDsegment-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