Public
Edited
Oct 17, 2023
Importers
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
suburbInformality2022 = aq
.from(await db2022.query(suburbQuery))
.derive({
PostCode: (d) => aq.op.parse_int(d.PostCode)
})
.join(incomeBySuburb2017, ["PostCode"])
Insert cell
Insert cell
Insert cell
fastDivisions = {
const map = new Map();

for (const division of selectedElection.divisionInformality) {
map.set(division.DivisionNm.toLowerCase(), division);
}

return map;
}
Insert cell
Insert cell
Insert cell
Insert cell
function getTooltip(d) {
const div = fastDivisions.get(d.properties.electorateName.toLowerCase());

return `${d.properties.electorateName}\n${div.InformalPercent.toFixed(
1
)}% informal\n${div.InformalSwing.toFixed(1)}% informal swing`;
}
Insert cell
getTooltip({ properties: { electorateName: "Blaxland" } })
Insert cell
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}%`
}
)
)
]
})
)
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more