Public
Edited
May 15
Insert cell
Insert cell
Insert cell
graph = {
const graph = layout(energy);
graph.nodes.forEach((node) => {
node.color = color(node.index / graph.nodes.length);
});
graph.links.forEach((link) => {
link.gradient = DOM.uid("gradient");
link.path = DOM.uid("path");
});
return graph;
}
Insert cell
layout = sankey.sankey()
.size(size)
.nodePadding(nodePadding)
.nodeWidth(nodeWidth)
Insert cell
format = (value) => {
let f = d3.format(",.0f");
return f(value) + " TWh";
}
Insert cell
color = (value) => {
return d3.interpolateRainbow(value);
}
Insert cell
Insert cell
size = [width - 2 * margin, height - 2 * margin]
Insert cell
height = 600
Insert cell
margin = 10
Insert cell
nodeWidth = 20
Insert cell
nodePadding = 10
Insert cell
duration = 250
Insert cell
arrow = "\u2192"
Insert cell
d3 = require("d3@5.9")
Insert cell
sankey = require("d3-sankey@0.12")
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more