Public
Edited
Jun 6, 2022
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
ipsBaiduLatestUrl = `${geoIpLookupsBucketUrl}/ips-baidu-latest.json`
Insert cell
latestIpsBaiduReport = (await fetch(ipsBaiduLatestUrl)).json()
Insert cell
chinaProvinces = FileAttachment("china-provinces.json").json()
Insert cell
chinaProvincesByCnName = d3.index(chinaProvinces, d => d.cn)
Insert cell
chinaProvincesByCode = d3.index(chinaProvinces, d => d.code)
Insert cell
Insert cell
latestPowerReport = (await fetch(`${minerPowerDailyAverageLatestBucketUrl}/miner-power-latest.json`)).json()
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
regionHierarchy = ({
name: 'root',
children: [
{
name: 'Mainland China',
code: 'CN',
note: 'Does not include Hong Kong, Taiwan'
},
{
name: 'USA',
code: 'US'
}
]
})
Insert cell
root = d3.hierarchy(_.cloneDeep(regionHierarchy))
Insert cell
graph(root, {label: d => `${d.data.code ? d.data.code + ': ' : ''}${d.data.name}`})
Insert cell
numberOfLeaves = root.copy().count().value
Insert cell
numberOfNodes = root.copy().sum(d => 1).value
Insert cell
indexedRoot = {
function childrenIndex(d) {
return d3.index(d.children.map(d => {
const value = d.data
if (value && value.children) {
value.children = childrenIndex(d)
}
return value
}), d => d.code)
}
return childrenIndex(root)
}
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
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
Insert cell
Insert cell
Insert cell
Insert cell
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