cooler hero chart title

This commit is contained in:
tmont 2020-04-28 22:22:17 -07:00
parent bf10251373
commit 0a72c63cdc
2 changed files with 9 additions and 2 deletions

View File

@ -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`);

View File

@ -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))},