Insert cell
Insert cell
Insert cell
Insert cell
data = {
let links = [];

const csvData = d3.csvParse(
await FileAttachment("data_sankey2@2.csv").text(),
d3.autoType
);

csvData.map((row, i) => {
links.push({
source: row["name"],
target: row["investorName"],
value: row["totalInvested"],
id: i
});
});

const nodes = Array.from(
new Set(links.flatMap((l) => [l.source, l.target])),
(name, id) => ({ name, id })
);

links.map((d) => {
d.source = nodes.find((e) => e.name === d.source).id;
d.target = nodes.find((e) => e.name === d.target).id;
});
return { nodes, links };
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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