Public
Edited
Mar 16, 2022
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
widthNow = d3.min([768, width]);
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
maxDatePlz = d3.max(dataPlz, d => d.Date)
Insert cell
Insert cell
anz = datenPlzTag.filter((obj) => obj.NewConfCases_7days === "199+").length
Insert cell
catPlz = distincts(datenPlzTag, "NewConfCases_7days").sort(
(a, b) => a.replace('+', '').split('-')[0] - b.replace('+', '').split('-')[0]
)
Insert cell
mapDataRegions = d3.json(
"https://raw.githubusercontent.com/openZH/covid_19/master/fallzahlen_bezirke/BezirkeAlleSee_gen_epsg2056_F_KTZH_2020.json"
)
Insert cell
Insert cell
Insert cell
Insert cell
mapDataRegions4326 = d3.json(
"https://raw.githubusercontent.com/openZH/covid_19/master/fallzahlen_bezirke/BezirkeAlleSee_gen_epsg4326_F_KTZH_2020.json"
)
Insert cell
mapPlz2056 = d3.json("https://raw.githubusercontent.com/openZH/covid_19/master/fallzahlen_plz/PLZ_gen_epsg2056_F_KTZH_2020.json")
Insert cell
Insert cell
Insert cell
anzJahre = Math.floor(+week_extent[1] / 52)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
colorInterpolater = d3.interpolateGreens
Insert cell
generateColorArray = function(n) {
let arr = [];

for (var i = 0; i < n; i++) {
arr.push(colorInterpolater(i / (n - 1)));
}
return arr;
}
Insert cell
generateColorArray(catPlz.length)
Insert cell
Insert cell
Insert cell
function ramp(color, n = 256) {
const canvas = DOM.canvas(n, 1);
const context = canvas.getContext("2d");
for (let i = 0; i < n; ++i) {
context.fillStyle = color(i / (n - 1));
context.fillRect(i, 0, 1, 1);
}
return canvas;
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
yScaleArea = d3.scaleLinear()
.range([height - margin.bottom, margin.top])
Insert cell
Insert cell
Insert cell
Insert cell
projectionPlz = d3
.geoIdentity()
.reflectY(true)
.fitExtent(
[[padding, padding], mapSize.map(d => d - padding)],
mapPlz2056
)
Insert cell
Insert cell
pathPlz = d3.geoPath(projectionPlz);
Insert cell
Insert cell
Insert cell
Insert cell
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