Public
Edited
Sep 9, 2023
Insert cell
Insert cell
md`Just a playground`
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof xSpread = html`<input type=range min=0 max=100 value=35>`;
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
leafForce = d3.forceY().y(node => yDist * node.distance);
Insert cell
Insert cell
Insert cell
data = ({
nodes: rawData.nodes.map(node => ({
...node,
distance: distanceToLeaf(node.id)
})),
links: rawData.links
});
Insert cell
height = 600
Insert cell
color = {
const scale = d3.scaleOrdinal(d3.schemeCategory10);
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

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