Plot.plot({
title: "Population immigrée et étrangère depuis 1990 en France entière (1990-2023)",
y: {
grid: true,
label: "Nombre",
tickFormat: d3.format(" ")
},
x: {
axis: null,
domain: dataGrouped.Type
},
fx: {
domain: [...new Set(dataGrouped.map(d => d.Année))],
label: null,
tickFormat: d3.format("d")
},
color: {
domain: dataGrouped.Type,
scheme: "spectral",
legend: true
},
marks: [
Plot.ruleY([0]),
Plot.barY(dataGrouped, {
x: "Type",
y: "Nombre",
fill: "Type",
fx: "Année"
}),
Plot.text(dataGrouped, {
x: "Type",
y: "Nombre",
fx: "Année",
text: d => d3.format(" ")(d.Nombre),
dy: -5,
fill: "black",
fontSize: 10,
textAnchor: "middle"
})
]
})