data = {
const rawData = await d3.csv("https://covid.ourworldindata.org/data/owid-covid-data.csv", d3.autoType);
const totalCases = new Map(d3.groups(rawData, d => d.location).map(d => [d[0], d3.max(d[1], p => p.total_cases)]))
const data = rawData.filter(d => d.continent != null).filter(d => totalCases.get(d.location) != undefined)
const dates = Array.from(d3.group(data, d => +d.date).keys()).sort(d3.ascending).filter(d => new Date(d) > startingDate);
return {
dates: dates.map(d => new Date(d)),
series: (d3.groups(data, d => d.location).map(([name, values]) => {
const value = new Map(values.map(d => [+d.date, d.new_cases_smoothed_per_million]));
return {name: name + " - " + format(totalCases.get(name)), values: dates.map(d => value.get(d) == null ? 0 : value.get(d)), total_cases: totalCases.get(name)};
})).sort((a, b) => (b.total_cases - a.total_cases )).slice(0, numCountries)
};
}