Public
Edited
Apr 15, 2023
Fork of Blog Post
Insert cell
Insert cell
homeownerBreakdown = [
["Black", 37 ],
["Latinx", 57],
["Asian", 62],
["White", 76],
].map( ([key, rent]) => { return {demographic: key, rent: rent, own: 100 - rent}} )
Insert cell
rentalAssistanceBreakdown = [
["Black", [10, 4]],
["Latinx", [58, 50]],
["Asian", [2, 3]],
["White, Non-hispanic", [25, 42]],
["Other", [5, 1]],
].map( ([key, [recipients, overall]]) => {
return {
demographic: key,
rentalAssistanceRecipients: recipients,
overallPopulation: overall
}
})
Insert cell
rentalAssistanceBreakdownDemographics = rentalAssistanceBreakdown.map(({demographic}) => demographic)
Insert cell
rentalAssistanceBreakdown
X
overallPopulation
Y
rentalAssistanceRecipients
Color
demographic
Size
overallPopulation
Facet X
Facet Y
Mark
Auto
Type Chart, then Shift-Enter. Ctrl-space for more options.

Insert cell
{
let xDomain = ["rentalAssistanceRecipients", "overallPopulation"];
return Plot.plot({
x: {
axis: "top",
label: "Percent (%) ->"
},
y: {
axis: null,
// domain: rentalAssistanceBreakdownDemographics,
// label: "demographic"
},
color: {
scheme: "BuRd",
},
marks: [
Plot.ruleX([0]),
Plot.axisY({label: "demographic"}),
Plot.barX(rentalAssistanceBreakdown, {
x1: "rentalAssistanceRecipients",
x2: "overallPopulation",
y: "demographic",
fill: d => d.rentalAssistanceRecipients / d.overallPopulation,
})
]
})
}
Insert cell
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