Plot.plot({
title: `Population size`,
projection: {
type: "mercator",
rotate: [-10, 0],
domain: {
type: "FeatureCollection",
features: land.features.filter((d) =>
populationByCountry.get(d.properties.a3)
)
}
},
width,
height: width * 0.65,
marks: [
Plot.geo(
land.features,
Plot.centroid({
fill: (d) => populationByCountry.get(d.properties.a3),
stroke: "black",
strokeWidth: 0.25,
tip: true,
title: (d) => {
const count = populationByCountry.get(d.properties.a3);
return `${d.properties.name}\nPopulation: ${
count ? count.toLocaleString() : "No data"
}`;
}
})
)
],
color: {
type: "quantize",
domain: Array.from(populationByCountry.values()),
range: d3.schemeGreens[5],
unknown: "#ccc"
}
})