Public
Edited
Feb 25, 2024
1 star
Insert cell
md`# Nigeria Household: Amount spent on food`
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
getStateColor = (d) => {
const state =
d.properties.admin1Name === "Federal Capital Territory"
? "Abuja"
: d.properties.admin1Name;
return colorScale(meanSpendPerHeadByState[state]);
}
Insert cell
getStateSpend = (d) => {
const state =
d.properties.admin1Name === "Federal Capital Territory"
? "Abuja"
: d.properties.admin1Name;
return `${state}

₦${meanSpendPerHeadByState[state].toFixed(0)}`;
}
Insert cell
Insert cell
Insert cell
Insert cell
height = 300
Insert cell
householdData.length
Insert cell
d3.max(householdData, getSpendPerHead)
Insert cell
d3.max(householdData, d=>d.numberInHousehold)
Insert cell
Type JavaScript, then Shift-Enter. Ctrl-space for more options. Arrow ↑/↓ to switch modes.

Insert cell
meanSpendPerHeadRural = d3.mean(ruralHousehold, getSpendPerHead)
Insert cell
width = 700
Insert cell
d3 = require('d3@5')
Insert cell
import { histogram, ruralHousehold, urbanHousehold, householdData, states, zones, sectors } from '@thehogfather/nigeria-household-survey-wave4'
Insert cell
import { states as statesGeoJSON } from "@thehogfather/nigeria-geo-plot-templates"
Insert cell
import {vl} from '@vega/vega-lite-api'
Insert cell
import {select} from "@jashkenas/inputs"

Insert cell
Insert cell
Insert cell
import {legend} from "@d3/color-legend"

Insert cell
tippy = require('https://unpkg.com/tippy.js@6')
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