Public
Edited
Apr 7, 2024
Also listed in…
Global Mental Health
Insert cell
Insert cell
plot = Plot.plot({
caption:
"Data was reported by WHO member states between 2013–2017. Data from the WHO Global Health Observatory (2017).",
projection: "equal-earth",
// width,
color: {
legend: true,
label: "Psychiatrists per 100,000 people",
scheme: "viridis",
unknown: "white"
},
marginLeft: -150,
marks: [
Plot.geo(dataGeo, {
fill: (d) => d.properties["Psychiatrists"],
stroke: "currentColor",
strokeWidth: 0.5
}),
// Plot.sphere(),
Plot.tip(
dataGeo.features,
Plot.pointer(
Plot.centroid({
channels: {
Country: (d) => d.properties["Name"],
"Psychiatrists per 100k": (d) => d.properties["Psychiatrists"]
}
})
)
)
]
})
Insert cell
import { nameToCode, codeToName } from "@huw/iso-3166-1"
Insert cell
dataRaw = (await FileAttachment("data.json").json()).fact.map((d) => ({
Name: d.dims.COUNTRY,
Code: nameToCode[d.dims.COUNTRY],
Type: d.dims.GHO.replaceAll(
" working in mental health sector (per 100 000 population)",
""
),
Year: Number(d.dims.YEAR),
"Count per 100k": Number(d.Value)
}))
Insert cell
dataRaw
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
dataFlat = aq
.from(data)
.groupby(["Name", "Code", "Year"])
.pivot(["Type"], { "Count per 100k": (d) => aq.op.sum(d["Count per 100k"]) })
.ungroup()
.derive({
"All mental health workers": (d) =>
d["Nurses"] +
d["Psychiatrists"] +
d["Psychologists"] +
d["Social workers"]
})
.objects()
Insert cell
dataFlat
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
import { land110m as land, countries110m as countries } from "@visionscarto/geo"
Insert cell
dataGeo = ({
...countries,
features: countries.features.map((d1) => ({
...d1,
properties: {
...dataFlat.find((d2) => d2["Code"] === d1.properties.a3),
Name: codeToName[d1.properties.a3]
}
}))
})
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