Published
Edited
Apr 3, 2021
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
delayedData = {
let result = [];
let date = startDate;
const tomorrow = d3.timeFormat("%Y-%m-%d")(d3.timeDay.offset(Date.parse(today), 1));
while (date !== tomorrow) {
const data = await vaccineDataForDate(date);
const lastDate = data.slice(-1)[0]?.DATE;
const then = d3.sum(data, d => d.COUNT);
const now1 = d3.sum((await vaccineDataForDate(today)).filter(d => new Date(d.DATE) <= new Date(lastDate)), d => d.COUNT);
const now2 = d3.sum((await vaccineDataForDate(today)).filter(d => new Date(d.DATE) < new Date(date)), d => d.COUNT);
const now3 = d3.sum((await vaccineDataForDate(today)).filter(d => new Date(d.DATE) <= new Date(date)), d => d.COUNT);
const diff1 = now1 - then;
const diff2 = now2 - then;
const diff3 = now3 - then;
result.push({DATE: date, THEN: then, NOW1: now1, NOW2: now2, NOW3: now3, DIFF1: diff1, DIFF2: diff2, DIFF3: diff3, TYPE1: "eergisteren", TYPE2: "gisteren", TYPE3: "vandaag"});
date = d3.timeFormat("%Y-%m-%d")(d3.timeDay.offset(Date.parse(date), 1));
}
return result.filter(d => d.DATE !== "2021-03-21").filter(d => new Date(d.DATE) <= new Date(last_day));
}
Insert cell
await vaccineDataForDate(today)
Insert cell
Insert cell
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