plotInformalityDistribution = ({ data }) =>
addTooltips(
Plot.plot({
color: {
type: "linear",
domain: [0, INFORMALITY_SCALE_MAX],
scheme: "viridis",
label: "Informal voting (%) →",
legend: true
},
x: {
label: "Informal (%) →",
tickFormat: "%",
transform: (d) => d / 100
},
marks: [
Plot.rectY(
data,
Plot.binX(
{ y: "count" },
{
x: "InformalPercent",
fill: "InformalPercent",
title: (d) =>
`${d.SuburbNm ? d.SuburbNm + "\n" : ""}${d.DivisionNm} (${
d.StateAb
})\nInformal: ${(d.InformalPercent || 0).toFixed(
1
)}%\nInformal swing: ${d.InformalSwing}%`
}
)
)
]
})
)