Published
Edited
Feb 18, 2021
1 fork
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
drawSankey(data)
Insert cell
Insert cell
Insert cell
format = {
const format = d3.format(",.0f");
return data.units ? d => `${format(d)} ${data.units}` : format;
}
Insert cell
color = {
const color = d3.scaleOrdinal(d3.schemeCategory10);
return d => color(d.category === undefined ? d.name.replace('→', '').trim() : d.category);
}
Insert cell
data = {
const links = await FileAttachment("energy.csv").csv({typed: true});
const nodes = Array.from(new Set(links.flatMap(l => [l.source, l.target])), name => ({name, category: name.replace(/ .*/, "")}));
return {nodes, links, units: ""};
}
Insert cell
width = 954
Insert cell
height = 600
Insert cell
d3 = require("d3@6", "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