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 };
}