diff --git a/generate.js b/generate.js index 5755364..a3151c6 100755 --- a/generate.js +++ b/generate.js @@ -453,6 +453,7 @@ const processRecords = async () => { record.casesPerMillion = !!record.population ? record.cases.total / record.population * 1000000 : 0; record.deathGrowthRate = getGrowthRate(record.timeSeriesDaily); record.caseGrowthRate = getGrowthRate(record.cases.timeSeriesDaily); + record.caseFatalityRate = record.cases.total !== 0 ? record.total / record.cases.total : 0; }); tsGlobalRecords.sort((a, b) => { @@ -575,6 +576,7 @@ const processRecords = async () => { timeSeriesDaily: convertTsObjectToArray(item.cases.timeSeriesDaily), timeSeriesMonthly: convertTsObjectToArray(item.cases.timeSeriesMonthly), }, + caseFatalityRate: item.cases.total !== 0 ? item.total / item.cases.total : 0, }; stateItem.deathGrowthRate = getGrowthRate(stateItem.timeSeriesDaily); @@ -616,6 +618,7 @@ const processRecords = async () => { timeSeriesDaily: convertTsObjectToArray(item.cases.timeSeriesDaily), timeSeriesMonthly: convertTsObjectToArray(item.cases.timeSeriesMonthly), }, + caseFatalityRate: item.cases.total !== 0 ? item.total / item.cases.total : 0, }; countryItem.deathGrowthRate = getGrowthRate(countryItem.timeSeriesDaily); @@ -666,6 +669,7 @@ const processRecords = async () => { worldData.population = 7781841000; worldData.deathsPerMillion = worldData.total / worldData.population * 1000000; worldData.casesPerMillion = worldData.cases.total / worldData.population * 1000000; + worldData.caseFatalityRate = worldData.cases.total !== 0 ? worldData.total / worldData.cases.total : 0; console.log(`transformed data in ${Date.now() - start}ms`); diff --git a/tmpl/master.pug b/tmpl/master.pug index 99363fa..3c36f1b 100644 --- a/tmpl/master.pug +++ b/tmpl/master.pug @@ -53,6 +53,10 @@ html background-color: #a65353; color: white; } + .other-bg-dark { + background-color: #336556; + color: white; + } .geo-bg { background-color: #eeeeee; } @@ -62,6 +66,9 @@ html .deaths-bg { background-color: #eac8c8; } + .other-bg { + background-color: #9ed0c2; + } .table-sm { font-size: 80%; } @@ -536,7 +543,7 @@ html th.text-center.font-weight-bold.geo-bg-dark(colspan=(hasPopulation ? 3 : 2)) Geography th.text-center.font-weight-bold.cases-bg-dark(colspan=(hasPopulation ? 6 : 5)) Cases th.text-center.font-weight-bold.deaths-bg-dark(colspan=(hasPopulation ? 6 : 5)) Deaths - th.text-center.font-weight-bold.geo-bg-dark Trends + th.text-center.font-weight-bold.other-bg-dark(colspan="2") Other thead.headers: tr th.geo-bg # th.geo-bg(data-col="name"): +sortableLinks("name", true)= label @@ -558,7 +565,10 @@ html th.deaths-bg(data-col="yesterday"): +sortableLinks("yesterday") Yesterday th.deaths-bg(data-col="last7"): +sortableLinks("last7") Last 7 th.deaths-bg(data-col="growth"): +sortableLinks("growth") Growth - th.text-center.geo-bg Last 14 days + + th.other-bg(data-col="cfr"): +sortableLinks("cfr") + acronym(title="Case Fatality Rate" style="border-bottom: 1px dotted #999999; cursor: help;") CFR + th.text-center.other-bg Trend - items.sort((a, b) => { @@ -599,6 +609,7 @@ html data-yesterday=yesterday data-last7=last7 data-growth=item.deathGrowthRate + data-cfr=item.caseFatalityRate ) td.sort-order= i + 1 td: +renderItemName(item) @@ -619,6 +630,7 @@ html td.text-right: code: +formatNumber(yesterday) td.text-right: code: +formatNumber(last7) td.text-right: code= Number(item.deathGrowthRate * 100).toFixed(2) + '%' + td.text-right: code= Number(item.caseFatalityRate * 100).toFixed(2) + '%' td canvas.mx-auto(id="sparkline-" + i width="100" height="35") script. @@ -732,6 +744,7 @@ html case 'population': case 'million': case 'growth': + case 'cfr': sortByNumberThenName(value); break; }