How to read and build a Sankey diagram
A Sankey diagram shows where a total goes. This post reads one of US energy flows, then builds it from a list of flows.
US energy flow from fuel source to end use, 2024. This chart is drawn in the browser.
Made with OpenChart. How to build this sankey diagram
A Sankey diagram reads from left to right. Vertical bars mark stages in a system, and curved bands show how much volume moves between them. Both node height and band width scale to the same unit, so a band twice as wide carries twice the quantity. Every unit that enters an intermediate stage leaves it on the right, so the chart tracks how a fixed total splits and merges.
In 2024, US power plants took in 32.79 quadrillion British thermal units (quads) of fuel and delivered less than half to homes, businesses, and factories. The rest left as rejected energy, mostly waste heat and grid losses, according to Lawrence Livermore National Laboratory.
US electricity generation flow, 2024. This chart is drawn in the browser.
Made with OpenChart. How to build this sankey diagram
Conservation of flow is what makes the middle node readable. Inputs from natural gas, nuclear, coal, and seven smaller sources add up to 32.79 quads, while the five outgoing bands sum to 32.77 quads because LLNL rounds each printed link label to two decimals. About 59% of the output exits directly into rejected energy, leaving residential, commercial, and industrial electricity to split the remaining share.
US energy flow from fuel to end use
Expanding from the power grid to the whole US economy adds a fourth column and brings the count to 42 links. Primary fuels enter on the left, pass through electricity generation or straight into four end-use sectors, and finish as energy services or rejected energy.
Most energy never passes through an electrical wire, and that bypass separates how the two largest fuels behave. Petroleum accounts for 35.59 quads, with about 70% going straight to transportation, where internal combustion engines lose most of it as rejected energy. Natural gas divides its 34.27 quads across power plants, factories, and buildings, with only a small share reaching transport. Coloring each ribbon by its source fuel keeps those overlapping paths legible across all four columns.
Across all 94.61 quads of 2024 US energy use, nearly two-thirds end as rejected energy and one-third become energy services (useful work like heating, lighting, and moving vehicles). Hovering a node or ribbon isolates its connected upstream and downstream paths.
US energy flow from fuel source to end use, 2024. This chart is drawn in the browser.
Made with OpenChart. How to build this sankey diagram
When a Sankey is the wrong chart
Sankey diagrams break down when values loop backward. Conservation from left to right assumes a directed acyclic graph, meaning flow moves forward through stages without returning to an earlier node. Cash circulating between accounts or recycled materials re-entering a factory create backward bands that cross the layout and obscure totals. A network graph or a transition matrix handles cyclic data cleanly.
Comparing two time periods with side-by-side Sankeys forces readers to judge band widths across separate panels. Aligned lengths along one axis are far easier to compare than curved ribbons separated by whitespace. To show how US fuel shares shifted between 2015 and 2024, draw a slope chart or a multi-line chart.
Dense graphs with dozens of minor categories collapse into unreadable hairlines and colliding labels. When the long tail carries little volume, group nodes below a share threshold into a single “Other” bucket so the main flows stay wide enough to label. If the data has only one split and no intermediate stages, skip the Sankey altogether and draw a horizontal bar chart or a 100% stacked bar.
The spec
The Code toggle under the first chart shows its full JSON spec. Setting "type": "sankey" selects the flow layout, and each row in data gives one directed link with source, target, and value fields. The encoding block maps those three fields and attaches a d3-format string (".2f") to value so every node label prints two decimal places.
Two top-level options manage color and clutter as a diagram grows. linkStyle controls ribbon color, defaulting to "gradient" between source and target, with "source" (used in the four-stage diagram above), "target", and "neutral" also available. Setting other to a fraction like 0.05 merges nodes under 5% of their column’s total into one “Other” node while keeping total flow unchanged. Titles and subtitles sit in chrome.
The first chart also sets nodeSort, a list of node ids from top to bottom, to choose where each node sits in its column. Its overrides block applies only on narrow screens: at 700 pixels wide or less, other folds the four fuels under 2% of the column into one “Other” node, so every label on a phone has room for its name and value.
For node alignment and custom “Other” buckets, read the Sankey documentation.