Published
Edited
Aug 17, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
randomTree = ((l = 10) => {
let category = 0;
const root = {id: -1, children: [], category};
const nodes = [root];
for (let i = 0; i < l; i++) {
if (Math.random() < 0.25) {
category++;
}
const j = Math.floor(Math.random() * (i + 1));
const n = {children: [], id: i, category};
nodes[j].children.push(n);
nodes.push(n);
}
return d3.hierarchy(root);
})(12)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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