Published
Edited
Oct 30, 2020
Insert cell
Insert cell
nodes = {
var ids = z.unique(z.getCol("Name", drop))
var nodes = []
ids.forEach(i =>
nodes.push({id: i, group: maptype[z.filter(r => r.Name == i, drop)[0].Type]})
)
// append report nodes
reports.forEach(i =>
nodes.push({id: i, group: maptype["report"]})
)
return nodes
}
Insert cell
Insert cell
data = {
const thing = {nodes: nodes, links:z.filter(r => r.source != undefined && r.target != undefined, links)}
return thing
}
Insert cell
ndata = await
d3.csv("https://gist.githubusercontent.com/linjac/87f35951ce00b4a7195e5c60c44f6d01/raw/f93190e0963fd1fb1b1d0163eac87c7c29c09856/network_data.csv")
Insert cell
drop = z.dropCol("Umbrella_org", z.dropCol("Umbrella_ID", ndata))
Insert cell
reports = z.unique(z.getCol("Report", drop))
Insert cell
committees = z.unique(z.getCol("Committee", drop))
Insert cell
maptype = {
let types = z.unique(z.getCol("Type", drop)).sort()
let maptype = {}
types.forEach((element,i) => maptype[element] = i)
maptype["report"] = Object.keys(maptype).length
return maptype
}
Insert cell
Insert cell
height = 600
Insert cell
d3.schemeCategory10
Insert cell
color = {
const scale = {0:"#e41a1c",1:"#377eb8",2:"#984ea3",3:"#4daf4a",4:"#ff7f00",5:"#f781bf"};
return d => scale[d.group];
}
Insert cell
drag = simulation => {
function dragstarted(d) {
if (!d3.event.active) simulation.alphaTarget(0.3).restart();
d.fx = d.x;
d.fy = d.y;
}
function dragged(d) {
d.fx = d3.event.x;
d.fy = d3.event.y;
}
function dragended(d) {
if (!d3.event.active) simulation.alphaTarget(0);
d.fx = null;
d.fy = null;
}
return d3.drag()
.on("start", dragstarted)
.on("drag", dragged)
.on("end", dragended);
}
Insert cell
d3 = require("d3@5")
Insert cell
z = require("zebras")
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