Published
Edited
Apr 13, 2021
2 stars
Insert cell
md`# #mannequinchallenge network graph`
Insert cell
Insert cell
Insert cell
Insert cell
ddata = {
let nodes = input_nodes.map(d => d.n);
let links = input_links.map(d => d.r);
return { nodes: nodes, links: links };
}
Insert cell
Insert cell
height = 500
Insert cell
color = {
// const scale = d3.scaleOrdinal(d3.schemeSet2);
// return d => scale(d.size/243);
return d => d.color
}
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

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

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