Sankey diagrams

Source: based on Department of Energy & Climate Change statistics (2014).

Sankey diagrams show the magnitude of flows between processes using the width of the lines. The example above shows the UK's energy balance, inspired by Mike Bostock's example. This diagram is produced using a new package, d3-sankey-diagram, which improves on the existing d3 sankey plugin in several ways — in particular:

Return loops

Nodes e and f are flowing from right to left.

Multiple types

Multiple types of flow can pass between the same nodes.

Dummy nodes

Nodes d and e are constrained to be in the same vertical layer, so 'dummy nodes' are added between a and e.

Getting started

Install using npm, or download the latest version from Github.

Use Jupyter notebook? Try ipysankeywidget, an interactive widget built on this d3 diagram.


API docs are on the wiki.

Try it!

Edit the JSON Sankey data below then click . Or try an example:


This library has been developed by Rick Lupton in the Use Less Group at the University of Cambridge. We made it to draw Sankey diagrams in the online Foreseer tool, which helps to explore the relationships between different resources: water, land and energy.

d3-sankey-diagram uses the MIT licence.

Fork me on GitHub