reg_growth_tot = regions_incidence.map(reg => {
const nSmth = 7;
const si = 5;
const casesGr = reg.series.map((s, idx) => {
if (idx<7) {
return null;
}
const c0 = reg.cases_todate[idx-7] - (reg.cases_todate[idx-8-nSmth] || 0);
const c1 = reg.cases_todate[idx] - reg.cases_todate[idx-1-nSmth];
return {
id: reg.id,
name: reg.name,
date: s.date,
population: reg.population,
cases_todate: reg.cases_todate[idx],
cases_todate_per100k: reg.cases_todate[idx]/reg.population*100000,
growth: c1/c0,
growth_nat: Math.pow(c1/c0, si/7)
};
});
return casesGr;
}).flat().filter(a => a && a.growth > 0 && Number.isFinite(a.growth));