This page fills in once the pipeline has run: targets::tar_make() locally, or the Data refresh GitHub Action.
Pick a province
prov = ready ? transpose(provinces) : []
dist = ready ? transpose(dists) : []
defaultProv = prov.some(d => d.province === "Tehran") ? "Tehran" : (prov[0] || {}).province
viewof province = Inputs.select(prov.map(d => d.province).sort(), {label: "Province", value: defaultProv})
viewof threshold = Inputs.radio(thresholds, {label: "Threshold (minutes)", value: ref})
sel = prov.find(d => d.province === province)
fmtPct = x => (x === null || x === undefined) ? "-" : `${Math.round(100 * x)}%`
fmtMin = x => (x === null || x === undefined) ? "-" : `${Math.round(x)} min`
fmtNum = x => (x === null || x === undefined) ? "-" : Math.round(x).toLocaleString("en-US")
ready && sel ? html`<div class="kpi-grid">
<div class="kpi"><span class="kpi-label">Within ${threshold} min</span><span class="kpi-value">${fmtPct(sel["share_within_" + threshold])}</span><span class="kpi-sub">${fmtNum(sel["pop_within_" + threshold])} of ${fmtNum(sel.population)} people</span></div>
<div class="kpi"><span class="kpi-label">Mean drive</span><span class="kpi-value">${fmtMin(sel.mean_travel_time_min)}</span><span class="kpi-sub">median ${fmtMin(sel.median_travel_time_min)}</span></div>
<div class="kpi"><span class="kpi-label">Hospitals mapped</span><span class="kpi-value">${fmtNum(sel.n_hospitals)}</span><span class="kpi-sub">${(sel.hospitals_per_100k ?? 0).toFixed(1)} per 100k people</span></div>
<div class="kpi"><span class="kpi-label">Rank at ${ref} min</span><span class="kpi-value">${sel.rank_coverage} / ${prov.length}</span><span class="kpi-sub">1 = best coverage</span></div>
</div>` : html``
colorFor = m => { const i = thresholds.findIndex(t => m < t); return palette[i === -1 ? thresholds.length : i]; }
ready ? Plot.plot({
height: 280,
marginLeft: 60,
style: {fontFamily: "IBM Plex Sans, sans-serif", fontSize: "14px", background: "transparent"},
color: {type: "identity"},
x: {label: "Drive time to nearest hospital (minutes) →", domain: [0, 190]},
y: {label: "↑ People", grid: true, tickFormat: "s"},
marks: [
Plot.rectY(dist.filter(d => d.province === province), {
x1: "bin_start", x2: d => d.bin_end ?? 190, y: "population",
fill: d => colorFor(d.bin_start), inset: 1
}),
Plot.ruleX([threshold], {stroke: "#13204A", strokeWidth: 2, strokeDasharray: "4,3"}),
Plot.ruleY([0])
]
}) : html``
Province ranking
Share of each province’s population within the selected drive time. Switch thresholds with the buttons.
How each province’s population splits by drive time