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

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more