Plot.plot({
width: width * 0.95,
marginLeft: 80,
marks: [
Plot.ruleY([0]),
Plot.dot(
[
...d3.rollup(
data,
(v) => d3.sum(v, (d) => d.people),
(d) => d.year
)
].map((d) => ({ year: new Date(d[0], 1, 1), people: d[1] })),
{
x: (d) => d["year"],
y: "people",
interval: "year",
tip: true,
title: (d, i) =>
[
"year = " + m(d.year).format("YYYY"),
"population = " + d.people.toLocaleString()
].join("\n")
}
)
]
})