addTooltips(
Plot.plot({
width: data.length * 40,
x: {axis: null, domain: periods},
y: {
grid: true,
nice: true,
tickFormat: "+s"
},
fx: {tickFormat: p => formatProvince(p)},
color: {scheme: "spectral", domain: periods, legend: true},
facet: {data: provincePopulationDifferences, x: "province"},
marks: [
Plot.barY(provincePopulationDifferences, {
x: "period",
y: "difference",
title: "difference",
fill: "period",
sort: {fx: "y", reduce: "sum", reverse: true}
}),
Plot.ruleY([0])
]
})
)