Public
Edited
Apr 7, 2024
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

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