Published
Edited
Jan 3, 2021
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
dataWithArrayChildren = ({
name: nameForRootNode,
children:
// 1. Array.from(iterable, mapFunction, thisArg)
Array.from(
// 2. d3.rollup(iterable, reduceFunction, ...keysToGroupBy)
d3.rollup(jsonData, data => data.length, ...keysToGroupBy),
// 3. arr.map((currentValue) => (returnValue))
([name, children]) => ({ name, children: Array.from(children, ([name,value]) => ({name,value})) })
)
});
Insert cell
Insert cell
Insert cell
d3.rollup(jsonData, data => data.length, ...keysToGroupBy)
Insert cell
Insert cell
d3.rollups(jsonData, data => data.length, ...keysToGroupBy)
Insert cell
Insert cell
Array.from(
d3.rollup(jsonData, data => data.length, ...keysToGroupBy),
([name, children]) => ({ name, children })
)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
keysToGroupBy = groupByPriority === "repo" ? [d => d.repo, d => d.component] : [d => d.component, d => d.repo];
Insert cell
nameForRootNode = "Platform"
Insert cell
Insert cell
hierarchyWithArrayChildren = d3.hierarchy(dataWithArrayChildren)
.sum(d => d.value)
.sort((a, b) => b.value - a.value)
Insert cell
hierarchyWithMapChildren = d3.hierarchy(d3.rollup(jsonData, d => d.length, ...keysToGroupBy))
.sum(([, value]) => value)
.sort((a, b) => b.value - a.value)
Insert cell
packWithArrayChildren = data => d3.pack()
.size([width - 2, height - 2])
.padding(3)
(hierarchyWithArrayChildren)
Insert cell
packWithMapChildren = data => d3.pack()
.size([width - 2, height - 2])
.padding(3)
(hierarchyWithMapChildren)
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