Published
Edited
Aug 10, 2021
6 forks
Importers
4 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
convertData = (data) => {
const sources = R.pluck("source")(data);
const targets = R.pluck("target")(data);
const uniqs = R.uniq(R.concat(sources, targets));
const nodes = R.map(R.objOf("name"), uniqs);
const nameToIndexEvolver = (el) => ({
source: R.indexOf(el.source, uniqs),
target: R.indexOf(el.target, uniqs),
value: el.value
});
const links = R.map(nameToIndexEvolver, data);
const graph = { nodes, links };
return graph;
}
Insert cell
convertData(exampleData)
Insert cell
Insert cell
viewof f = html`<input type=file accept="text/*">`
Insert cell
csvData = d3.csvParse(await Files.text(f))
Insert cell
Insert cell
Insert cell
dataPastedParsed = d3.tsvParse(pastedData)
Insert cell
Insert cell
Insert cell
Insert cell
format = {
const f = d3.format(",.0f");
return d => `${f(d)}`;
}
Insert cell
color = {
const color = d3.scaleOrdinal(d3.schemeCategory10);
return name => color(name.replace(/ .*/, ""));
}
Insert cell
width = 1200
Insert cell
height = 600
Insert cell
Insert cell
d3 = require("d3@5", "d3-sankey@0.12")
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