Unlisted
Edited
Jun 12, 2024
2 stars
Insert cell
Insert cell
Plot.plot({
width: 975,
height: 610 / 4,
projection: { type: "identity", domain: counties },
marks: [
Plot.geo(unemployment, {
geometry: (d) => features.get(d.id),
fill: "rate",
fx: "year"
}),
Plot.geo(states, { stroke: "white" })
]
})
Insert cell
// A Map for faster lookups
features = new Map(counties.features.map((d) => [d.id, d]))
Insert cell
Insert cell
// FAKE DATA
unemployment = {
const data = await FileAttachment("unemployment-x.csv").csv();
return data.flatMap((d) =>
["2013", "2014", "2015", "2016"].map((year) => ({
id: d.id,
year,
rate: +d.rate + 20 * Math.random()
}))
);
}
Insert cell
Insert cell
us = FileAttachment("counties-albers-10m.json").json()
Insert cell
counties = topojson.feature(us, us.objects.counties)
Insert cell
states = topojson.feature(us, us.objects.states)
Insert cell
statemap = new Map(states.features.map(d => [d.id, d]))
Insert cell
Insert cell
statemesh = topojson.mesh(us, us.objects.states, (a, b) => a !== b)
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