Public
Edited
Dec 4
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
mergeInAsChildOf = (B, A, nodeOfA) => {
// merge hierarchy B in hierarchy A as child of nodeOfA

B.parent = nodeOfA;
nodeOfA.children.push(B);
A = d3.hierarchy(A);
A.each((d) => (d.data = { ...d.data.data, children: d.children })); // fixes the glitch

return A;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
D = {
let D = d3.hierarchy({ name: "D" });
const A1 = A.copy(),
B1 = B.copy();

D.children = [A1, B1];
D = d3.hierarchy(D);
D.each((d) => (d.data = { ...d.data.data, children: d.children })); // fixes the glitch

return D;
}
Insert cell
graph(D, { label: (d) => d.data.name })
Insert cell
import { graph } from "@d3/d3-hierarchy"
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