added last14/1m data

This commit is contained in:
tmont 2020-05-31 23:41:21 -07:00
parent e5046e24e1
commit 0e69e64831
2 changed files with 53 additions and 15 deletions

View File

@ -660,7 +660,7 @@ const processRecords = async () => {
worldData.cases.timeSeriesMonthly = convertTsObjectToArray(worldData.cases.timeSeriesMonthly); worldData.cases.timeSeriesMonthly = convertTsObjectToArray(worldData.cases.timeSeriesMonthly);
worldData.deathGrowthRate = getGrowthRate(worldData.timeSeriesDaily); worldData.deathGrowthRate = getGrowthRate(worldData.timeSeriesDaily);
worldData.casesGrowthRate = getGrowthRate(worldData.cases.timeSeriesDaily); worldData.caseGrowthRate = getGrowthRate(worldData.cases.timeSeriesDaily);
worldData.rollingAverageDaily = getRollingAverage(worldData); worldData.rollingAverageDaily = getRollingAverage(worldData);
worldData.doublingDaily = getDoublingTime(worldData); worldData.doublingDaily = getDoublingTime(worldData);
worldData.cases.rollingAverageDaily = getRollingAverage(worldData.cases); worldData.cases.rollingAverageDaily = getRollingAverage(worldData.cases);

View File

@ -7,6 +7,10 @@ html
link(rel="stylesheet" href="/bootstrap.css") link(rel="stylesheet" href="/bootstrap.css")
script(src="/Chart.bundle.js") script(src="/Chart.bundle.js")
style. style.
acronym, abbr {
border-bottom: 1px dotted #999999;
cursor: help;
}
table td { table td {
vertical-align: middle !important; vertical-align: middle !important;
} }
@ -463,13 +467,13 @@ html
div.card.mb-4 div.card.mb-4
div.card-body.position-relative div.card-body.position-relative
div.position-absolute(style="top: 10px; right: 10px; z-index: 2;") div.position-absolute(style="top: 10px; right: 10px; z-index: 2;")
div.btn-group div.btn-group.btn-group-sm
button.btn.btn-secondary.btn-sm.set-axis-linear( button.btn.btn-secondary.set-axis-linear(
type="button" type="button"
onclick="setAxisType('linear')" onclick="setAxisType('linear')"
autocomplete="off" autocomplete="off"
) Linear ) Linear
button.btn.btn-secondary.btn-sm.set-axis-logarithmic( button.btn.btn-secondary.set-axis-logarithmic(
type="button" type="button"
onclick="setAxisType('logarithmic')" onclick="setAxisType('logarithmic')"
autocomplete="off" autocomplete="off"
@ -478,12 +482,17 @@ html
div.mx-auto.position-relative(style="max-width: 1024px; z-index: 1") div.mx-auto.position-relative(style="max-width: 1024px; z-index: 1")
canvas.mx-auto(id="main-chart" width="1024" height="576") canvas.mx-auto(id="main-chart" width="1024" height="576")
- -
const growthRate = '+' + (data.deathGrowthRate * 100).toFixed(2) + '%'; const deathGrowthRate = '+' + (data.deathGrowthRate * 100).toFixed(2) + '%';
const caseGrowthRate = '+' + (data.caseGrowthRate * 100).toFixed(2) + '%';
const population = 'pop. ' + data.population.toLocaleString(); const population = 'pop. ' + data.population.toLocaleString();
const deathsPerMillion = Math.round(data.deathsPerMillion).toLocaleString() + '/MM'; const deathsPerMillion = Math.round(data.deathsPerMillion).toLocaleString() + '/1M';
const casesPerMillion = Math.round(data.casesPerMillion).toLocaleString() + '/1M';
const totalDeaths = data.total.toLocaleString();
const totalCases = data.cases.total.toLocaleString();
const heroTitle = [ const heroTitle = [
'Covid-19: ' + data.name, `Covid-19: ${data.name} (${population})`,
`${population} | ${deathsPerMillion} | ${growthRate}` `${totalCases} cases (${casesPerMillion}, ${caseGrowthRate})`,
`${totalDeaths} deaths (${deathsPerMillion}, ${deathGrowthRate})`,
]; ];
script. script.
makeHeroChart( makeHeroChart(
@ -505,8 +514,8 @@ html
div#table: table.table.table-sm.table-hover div#table: table.table.table-sm.table-hover
thead: tr thead: tr
th.text-center.font-weight-bold.geo-bg-dark(colspan=(hasPopulation ? 3 : 2)) Geography 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.cases-bg-dark(colspan=(hasPopulation ? 7 : 5)) Cases
th.text-center.font-weight-bold.deaths-bg-dark(colspan=(hasPopulation ? 6 : 5)) Deaths th.text-center.font-weight-bold.deaths-bg-dark(colspan=(hasPopulation ? 7 : 5)) Deaths
th.text-center.font-weight-bold.other-bg-dark(colspan="2") Other th.text-center.font-weight-bold.other-bg-dark(colspan="2") Other
thead.headers: tr thead.headers: tr
th.geo-bg # th.geo-bg #
@ -519,7 +528,10 @@ html
th.cases-bg(data-col="cases-total"): +sortableLinks("cases-total") Total th.cases-bg(data-col="cases-total"): +sortableLinks("cases-total") Total
th.cases-bg(data-col="cases-today"): +sortableLinks("cases-today") Today th.cases-bg(data-col="cases-today"): +sortableLinks("cases-today") Today
th.cases-bg(data-col="cases-yesterday"): +sortableLinks("cases-yesterday") Yesterday th.cases-bg(data-col="cases-yesterday"): +sortableLinks("cases-yesterday") Yesterday
th.cases-bg(data-col="cases-last7"): +sortableLinks("cases-last7") Last 7 th.cases-bg(data-col="cases-last14"): +sortableLinks("cases-last14"): abbr(title="Last 14 days") L14
if hasPopulation
th.cases-bg(data-col="cases-last14-million")
+sortableLinks("cases-last14-million"): abbr(title="Last 14 days per million residents") L14/1M
th.cases-bg(data-col="cases-growth"): +sortableLinks("cases-growth") Growth th.cases-bg(data-col="cases-growth"): +sortableLinks("cases-growth") Growth
if hasPopulation if hasPopulation
@ -527,11 +539,14 @@ html
th.deaths-bg(data-col="total"): +sortableLinks("total") Total th.deaths-bg(data-col="total"): +sortableLinks("total") Total
th.sorted.deaths-bg(data-col="today"): +sortableLinks("today") Today th.sorted.deaths-bg(data-col="today"): +sortableLinks("today") Today
th.deaths-bg(data-col="yesterday"): +sortableLinks("yesterday") Yesterday th.deaths-bg(data-col="yesterday"): +sortableLinks("yesterday") Yesterday
th.deaths-bg(data-col="last7"): +sortableLinks("last7") Last 7 th.deaths-bg(data-col="last14"): +sortableLinks("last14"): abbr(title="Last 14 days") L14
if hasPopulation
th.deaths-bg(data-col="last14-million")
+sortableLinks("last14-million"): abbr(title="Last 14 days per million residents") L14/1M
th.deaths-bg(data-col="growth"): +sortableLinks("growth") Growth th.deaths-bg(data-col="growth"): +sortableLinks("growth") Growth
th.other-bg(data-col="cfr"): +sortableLinks("cfr") th.other-bg(data-col="cfr"): +sortableLinks("cfr")
acronym(title="Case Fatality Rate" style="border-bottom: 1px dotted #999999; cursor: help;") CFR acronym(title="Case Fatality Rate") CFR
th.text-center.other-bg Trend th.text-center.other-bg Trend
- -
@ -557,6 +572,10 @@ html
const casesToday = getDeltaCases(1); const casesToday = getDeltaCases(1);
const casesLast7 = getValueCases(1) - getValueCases(7); const casesLast7 = getValueCases(1) - getValueCases(7);
const casesYesterday = getDeltaCases(2); const casesYesterday = getDeltaCases(2);
const last14 = getValue(1) - getValue(14);
const casesLast14 = getValueCases(1) - getValueCases(14);
const last14Avg = hasPopulation && item.population ? last14 * 1000000 / item.population : null;
const casesLast14Avg = hasPopulation && item.population ? casesLast14 * 1000000 / item.population : null;
tr( tr(
id=("row-" + (item.safeName || '_')) id=("row-" + (item.safeName || '_'))
data-name=(item.name || '_') data-name=(item.name || '_')
@ -566,12 +585,16 @@ html
data-cases-million=item.casesPerMillion data-cases-million=item.casesPerMillion
data-cases-yesterday=casesYesterday data-cases-yesterday=casesYesterday
data-cases-growth=item.caseGrowthRate data-cases-growth=item.caseGrowthRate
data-cases-last14=casesLast14
data-cases-last14-million=casesLast14Avg
data-population=item.population data-population=item.population
data-total=item.total data-total=item.total
data-million=item.deathsPerMillion data-million=item.deathsPerMillion
data-today=today data-today=today
data-yesterday=yesterday data-yesterday=yesterday
data-last7=last7 data-last7=last7
data-last14=last14
data-last14-million=last14Avg
data-growth=item.deathGrowthRate data-growth=item.deathGrowthRate
data-cfr=item.caseFatalityRate data-cfr=item.caseFatalityRate
) )
@ -585,14 +608,18 @@ html
td.text-right: code: +formatNumber(item.cases.total) td.text-right: code: +formatNumber(item.cases.total)
td.text-right: code: +formatNumber(casesToday) td.text-right: code: +formatNumber(casesToday)
td.text-right: code: +formatNumber(casesYesterday) td.text-right: code: +formatNumber(casesYesterday)
td.text-right: code: +formatNumber(casesLast7) td.text-right: code: +formatNumber(casesLast14)
if hasPopulation
td.text-right: code: +formatNumber(Math.round(casesLast14Avg))
td.text-right: code= Number(item.caseGrowthRate * 100).toFixed(2) + '%' td.text-right: code= Number(item.caseGrowthRate * 100).toFixed(2) + '%'
if hasPopulation if hasPopulation
td.text-right: code: +formatNumber(Math.round(item.deathsPerMillion)) td.text-right: code: +formatNumber(Math.round(item.deathsPerMillion))
td.text-right: code: +formatNumber(item.total) td.text-right: code: +formatNumber(item.total)
td.text-right.sorted: code: +formatNumber(today) td.text-right.sorted: code: +formatNumber(today)
td.text-right: code: +formatNumber(yesterday) td.text-right: code: +formatNumber(yesterday)
td.text-right: code: +formatNumber(last7) td.text-right: code: +formatNumber(last14)
if hasPopulation
td.text-right: code: +formatNumber(Math.round(last14Avg))
td.text-right: code= Number(item.deathGrowthRate * 100).toFixed(2) + '%' td.text-right: code= Number(item.deathGrowthRate * 100).toFixed(2) + '%'
td.text-right: code= Number(item.caseFatalityRate * 100).toFixed(2) + '%' td.text-right: code= Number(item.caseFatalityRate * 100).toFixed(2) + '%'
td td
@ -699,6 +726,13 @@ html
return aName.localeCompare(bName); return aName.localeCompare(bName);
} }
if (aValue === null) {
return 1;
}
if (bValue === null) {
return -1;
}
return aValue < bValue ? return aValue < bValue ?
(newSortDir === 'asc' ? -1 : 1) : (newSortDir === 'asc' ? -1 : 1) :
(newSortDir === 'asc' ? 1 : -1); (newSortDir === 'asc' ? 1 : -1);
@ -725,10 +759,14 @@ html
case 'cases-yesterday': case 'cases-yesterday':
case 'cases-million': case 'cases-million':
case 'cases-last7': case 'cases-last7':
case 'cases-last14':
case 'cases-last14-million':
case 'cases-growth': case 'cases-growth':
case 'today': case 'today':
case 'yesterday': case 'yesterday':
case 'last7': case 'last7':
case 'last14':
case 'last14-million':
case 'population': case 'population':
case 'million': case 'million':
case 'growth': case 'growth':