Public
Edited
Apr 2, 2024
Insert cell
Insert cell
Insert cell
Plot.plot({
caption:
"Data on prevalence is estimated from real data sources and statistical models for the region. Data from the WHO Global Health Observatory (2015).",
projection: "equal-earth",
width,
color: {
legend: true,
type: "log",
label: "Ratio of Depression Prevalence to Life Satisfaction",
scheme: "magma",
unknown: "white"
},
marks: [
Plot.geo(dataGeo, {
fill: (d) =>
d.properties["Ratio of Depression Prevalence to Life Satisfaction"],
stroke: "currentColor",
strokeWidth: 0.5
}),
Plot.sphere(),
Plot.tip(
dataGeo.features,
Plot.pointer(
Plot.centroid({
channels: {
Country: (d) => d.properties["Name"],
Ratio: (d) =>
d.properties[
"Ratio of Depression Prevalence to Life Satisfaction"
]
}
})
)
)
]
})
Insert cell
import { depressionPrevalenceProportionPerCountry2015 as gho } from "@huw/gho"
Insert cell
import { dataSnapshot as whr } from "@huw/whr"
Insert cell
import { countries110m as countries } from "@visionscarto/geo"
Insert cell
import { fixCode, codeToName } from "@huw/iso-3166-1"
Insert cell
data = aq
.from(whr)
.select(aq.not("Year"))
.join(aq.from(gho), "Code", [
aq.all(),
{ "Proportion of Depression": (d) => d["Proportion"] }
])
.derive({
"Ratio of Depression Prevalence to Life Satisfaction": (d) =>
d["Proportion of Depression"] / d["Cantril Ladder Score"]
})
.objects()
Insert cell
data
Type Table, then Shift-Enter. Ctrl-space for more options.

Insert cell
dataGeo = ({
...countries,
features: countries.features.map((d1) => ({
...d1,
properties: {
...data.find((d2) => d2["Code"] === fixCode(d1.properties.a3)),
Name: codeToName[fixCode(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