diff --git a/generate.js b/generate.js index e277ca7..bfa232b 100755 --- a/generate.js +++ b/generate.js @@ -531,6 +531,8 @@ const processGlobalDeaths = async () => { }); worldData.deathGrowthRate = getGrowthRate(worldData); + worldData.population = 7781841000; + worldData.deathsPerMillion = worldData.total / worldData.population * 1000000; console.log(`transformed data in ${Date.now() - start}ms`); diff --git a/tmpl/master.pug b/tmpl/master.pug index 19364ae..5bc59cb 100644 --- a/tmpl/master.pug +++ b/tmpl/master.pug @@ -203,7 +203,7 @@ html span.d-inline-block.text-truncate block - mixin heroChart(title) + mixin heroChart() div.card.mb-4 div.card-body.position-relative div.position-absolute(style="top: 10px; right: 10px") @@ -220,10 +220,15 @@ html autocomplete="off" ) Logarithmic canvas.mx-auto(id="main-chart" width="800" height="450") + - + const growthRate = '+' + (data.deathGrowthRate * 100).toFixed(2) + '%'; + const population = 'pop. ' + data.population.toLocaleString(); + const deathsPerMillion = Math.round(data.deathsPerMillion) + '/million'; + const heroTitle = data.name + ` (${population}, ${deathsPerMillion}, ${growthRate})`; script. makeHeroChart( 'main-chart', - !{JSON.stringify(data.name + ' (' + (data.deathGrowthRate < 0 ? '' : '+') + (data.deathGrowthRate * 100).toFixed(2) + '%)')}, + !{JSON.stringify(heroTitle)}, !{JSON.stringify(data.timeSeriesDaily.map(x => x.key))}, !{JSON.stringify(data.timeSeriesDaily.map(x => x.value))}, !{JSON.stringify(data.timeSeriesDaily.map(x => x.delta))},