Published unlisted
Edited
Mar 29, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
data = [
{name: "Floyd Mayweather", sport: "Boxing", nation: "United States", earnings: 285},
{name: "Lionel Messi", sport: "Soccer", nation: "Argentina", earnings: 111},
{name: "Cristiano Ronaldo", sport: "Soccer", nation: "Portugal", earnings: 108},
{name: "Conor McGregor", sport: "MMA", nation: "Ireland", earnings: 99},
{name: "Neymar", sport: "Soccer", nation: "Brazil", earnings: 90},
{name: "LeBron James", sport: "Basketball", nation: "United States", earnings: 85.5},
{name: "Roger Federer", sport: "Tennis", nation: "Switzerland", earnings: 77.2},
{name: "Stephen Curry", sport: "Basketball", nation: "United States", earnings: 76.9},
{name: "Matt Ryan", sport: "Football", nation: "United States", earnings: 67.3},
{name: "Matthew Stafford", sport: "Football", nation: "United States", earnings: 59.5}
]
Insert cell
Insert cell
flare = FileAttachment("flare.json").json()
Insert cell
Insert cell
({
name: "root",
children: [
{
name: "United States",
children: {
name: "Boxing",
children: {
name: "Stephen Curry",
earnings: 76.9
}
}
}
]
})
Insert cell
Insert cell
group = d3.group(data, d => d.nation, d => d.sport, d => d.name)
Insert cell
hierarchy = d3.hierarchy(group)
Insert cell
hierarchyFlare = d3.hierarchy(flare)
Insert cell
Insert cell
d3 = require("d3@6")
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