Published
Edited
Feb 7, 2022
2 stars
Insert cell
Insert cell
Insert cell
Insert cell
packit(hierarchy)
Insert cell
packit = d3.pack()
.size([width - 2, height - 2]) // can I set a min circle size?
.padding(1)


Insert cell
// first, get data into hierarchical structure
hierarchy = {
let h = d3.stratify()
.id(d => d.id)
.parentId(d => d.type)
(allNodes) // parse the nodes

// then use d3.hierarchy to calculate the size of each circle

return d3.hierarchy(h).sum(d => 1) // added a value that represent the number of elements in each type
// in this case the number of signtures in the city
}
Insert cell
allNodes = {

let addedID = suffragist.map(d=>{ // Appends the id and type to the dataset
d.id = 'child'
d.type = d.consistentCityRegion
return d
})
return _.union( // @shierlys magic
[{id: 'root', type: ''}],
_.map(typeIDs, id => new Object({id, type: 'root'})),
addedID,
)
}
Insert cell
Insert cell
runonce = [false]
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
Insert cell
baseURL+suffragist[0].sheetURL // example of entry
Insert cell
Table(suffragist)
Insert cell
Table(allNodes)
Insert cell
Insert cell
import {Table, Search} from "@observablehq/inputs"
Insert cell
d3 = require('d3@6')
Insert cell
_ = require('lodash')
Insert cell
<style>

.katex-display,p,ul,h1,h2,h3,h4,li
{
font-family: sans-serif;
}

@media (hover: hover) {
.katex-display,p,ul,h1,h2,h3,h4,li {
max-width: ${width-14}px;
min-width: ${800}px; }
}
</style>
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more