Published
Edited
Jun 7, 2022
1 star
Insert cell
Insert cell
Insert cell
topLevelItems = {
const open = [];
const closed = [];
const children = d3.select(list).selectChildren("li");

for (const child of children) {
const selectedChild = d3.select(child);
const stricken = selectedChild.selectChild("del");

if (stricken.size()) {
closed.push(stricken.node().innerText);
} else {
open.push(selectedChild.node().innerText);
}
}

return { closed, open };
}
Insert cell
altTopLevelItems = {
const open = [];
const closed = [];
const children = list.querySelectorAll(":scope > li"); // Direct children only

for (const child of children) {
const selectedChild = d3.select(child);
const stricken = child.querySelector("del");

if (stricken) {
closed.push(stricken.innerText);
} else {
open.push(child.innerText);
}
}

return { closed, open };
}
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