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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more