Plot.plot({
marks: [
Plot.ruleY([0]),
Plot.line(
d3.rollups(
jobs.filter(d => d.job.includes("Apprentice")),
v => d3.sum(v, d => d.count),
d => d.year
).map(([year, totalApprentices]) => ({ year, totalApprentices })),
{ x: "year", y: "totalApprentices", stroke: "green", strokeWidth: 2, tip: true }
)
],
width: 600,
height: 400,
x: { label: "Year" },
y: { label: "Total Apprentices" }
})