Sankey diagram component

This diagram show how energy is converted or transmitted before being consumed or lost: supplies are on the left, and demands are on the right. Data: Department of Energy & Climate Change via Tom Counsell

Source TWh
Agricultural 'waste' 124.7
Bio-conversion 388.9
Biofuel imports 35
Biomass imports 35
Coal imports 11.6
Coal reserves 64
Coal 75.6
District heating 79.3
Electricity grid 918.6
Gas imports 40.7
Gas reserves 82.2
Gas 204.1
Geothermal 7
H2 conversion 27.1
H2 20.9
Hydro 7
Liquid 647.6
Marine algae 4.4
Ngas 123
Nuclear 840
Oil imports 504.3
Oil reserves 107.7
Oil 612
Other waste 134.4
Pumped heat 263.7
Solar PV 59.9
Solar Thermal 19.3
Solar 79.2
Solid 447.5
Thermal generation 1,392
Tidal 9.5
UK land based bioenergy 182
Wave 19
Wind 289.4
Losses 878.3
Industry 568.9
Heating and cooling - commercial 134.2
Heating and cooling - homes 372.2
Over generation / exports 104.5
Road transport 194.5
Agriculture 11
Rail transport 12.3
Lighting & appliances - commercial 90
Lighting & appliances - homes 93.5
International shipping 128.7
Domestic aviation 14.5
International aviation 206.3
National navigation 33.2

Energy Flow Links

Source Target TWh
Agricultural 'waste' → Bio-conversion 124.7
Bio-conversion → Liquid 0.6
Bio-conversion → Losses 26.9
Bio-conversion → Solid 280.3
Biofuel imports → Liquid 81.1
Biomass imports → Solid 35
Coal imports → Coal 35
Coal reserves → Coal 11.6
Coal → Solid 64
District heating → Industry 75.6
Electricity grid → Over generation / exports 46.2
Electricity grid → Heating and cooling - homes 104.5
Gas → Heating and cooling - commercial 82.2
H2 conversion → H2 7
Hydro → Electricity grid 20.9
Liquid → Industry 7
Marine algae → Bio-conversion 4.4
Nuclear → Thermal generation 123
Oil → Liquid 107.7
Solid → Thermal generation 0.9

How do I use this code? 🤔

To use this chart outside of Observable, copy-paste the entire function SankeyChart below including the copyright notice into your application. You’ll also need to install ( e.g., yarn add d3 d3-sankey) and import ( e.g., import * as d3 from "d3", import * as d3Sankey from "d3-sankey") D3; see D3’s README for details.

Example Code

chart=SankeyChart({
    links: energy
}, {
    nodeGroup: d => d.id.split(/\W/)[0],  // take first word for color
    nodeAlign,                            // e.g., d3.sankeyJustify; set by input above
    linkColor,                            // e.g., "source" or "target"; set by input above
    format: (f => d => `${f(d)} TWh`)(d3.format(",.1~f")),
    width,
    height: 600
});

To use this chart on Observable, import it into your notebook:

import {SankeyChart} from "@d3/sankey-component"

Then call SankeyChart(data, options) as shown above.

Customizing the Chart

To customize this chart, click the Fork button at the top of the page to create your own copy of this notebook and save your changes.