Published
Edited
Dec 3, 2018
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
radialTree = data => d3.tree()
.size([2 * Math.PI, width / 2])
.separation((a, b) => (a.parent == b.parent ? 1 : 2) / a.depth)
(stratifiedData)
Insert cell
stratifiedData = d3.stratify()
.id(d => d['GEO.display-label'])
.parentId(d => d.parent)
([
...flattenObject(sortedByRelativePopToCounty(bayAreaCities)),
...counties.filter(d => bayAreaCounties.includes(d['GEO.display-label'])),
{
'GEO.display-label': 'California',
parent: ''
}
])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
function flattenObject(obj) {
let flattened = [];
for (let key in obj) {
flattened = [...flattened, ...obj[key]];
}
return flattened;
}
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