Published
Edited
Jul 26, 2021
2 stars
Insert cell
Insert cell
Insert cell
formatted = prettier.format(code, {
parser: "babel",
printWidth: chars,
plugins: [prettier]
})
Insert cell
charWidth = 8
Insert cell
chars = Math.floor(width / charWidth)
Insert cell
code = `function select(select) {
var subgroups = [],
subgroup,
subnode,
group,
node;
for (var j = 0, m = groups.length; j < m; j++) {
group = groups[j];
subgroups.push((subgroup = []));
subgroup.parentNode = group.parentNode;
subgroup.parentData = group.parentData;
for (var i = 0, n = group.length; i < n; i++) {
if ((node = group[i])) {
subgroup.push((subnode = select(node)));
if (subnode && "__data__" in node) subnode.__data__ = node.__data__;
} else {
subgroup.push(null);
}
}
}
return d3_selection(subgroups);
}`
Insert cell
prettier = require("prettier@2", "prettier@2/parser-babel.js")
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