Public
Edited
May 7, 2023
Insert cell
Insert cell
Insert cell
Choroplethi = Plot.plot({
projection: projectioni,
marks: [
Plot.geo(polygonsi, {
stroke: "white",
fill: (d) => Age_fill.get(d.properties.gen),
title: (d) =>
`${d.properties.gen} ${format(Age_2021M.get(d.properties.gen))}`
}),
Plot.geo(polygonsi, { strokeWidth: 0.05 }),
Plot.geo(polygonsi, { stroke: "#fff", strokeWidth: .5 })
],
color: {
scheme: "Blues",
type: "quantile",
label: "Average Age by region",
legend: true,
domain: [40, 50]
}
})
Insert cell
Insert cell
Insert cell
Insert cell
csv_datai = FileAttachment("AveAgesdiff.csv").csv().then(data => data.map(d => ({region: d.gen, year: +d.jahr, age: +d.wert})))
Insert cell
//datai = Object.assign(new Map(d3.csvParse(await FileAttachment("AveAgesdiff.csv").text(), ({gen, jahr, wert}) => [gen, [+jahr, +wert]])), {title: ["Year", "Average Age"]})
Insert cell
Age_2021 = csv_datai.filter(d => d.year === 2021)
Insert cell
Age_2021M = new Map(Age_2021.map(({region, age}) => [region, age]))
Insert cell
Germanyi = FileAttachment("Ages0to19.json").json()
Insert cell
polygonsi = topojson.feature(Germanyi, Germanyi.objects.Ages_0to19_wgs84)
Insert cell
format = d3.format(".1f")
Insert cell
projectioni = d3i.geoTransverseMercator().rotate([-5,0]).fitExtent([[10, 10], [850, 400]], polygonsi);
Insert cell
sliderYear = csv_datai.filter(d => d.year === Select)
Insert cell
Age_fill = new Map(sliderYear.map(({region, age}) => [region, age]))
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