Published
Edited
Oct 13, 2020
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
widthNow = d3.min([768, width]);
Insert cell
Insert cell
Insert cell
maxDate = d3.max(dataPlz, d => d.Date);
Insert cell
Insert cell
catPlz = distincts(datenPlzTag, "NewConfCases_7days").sort(
(a, b) => 1*a.split('-')[0] - 1*b.split('-')[0]
)
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
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
yScaleArea = d3.scaleLinear()
.range([height - margin.bottom, margin.top])
Insert cell
projectionPlz = d3
.geoIdentity()
.reflectY(true)
.fitExtent(
[[padding, padding], mapSize.map(d => d - padding)],
mapPlz2056
)
Insert cell
pathPlz = d3.geoPath(projectionPlz);
Insert cell
Insert cell
Insert cell
Insert cell
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