diff --git a/generate.js b/generate.js index 403474f..a0efe4e 100755 --- a/generate.js +++ b/generate.js @@ -312,6 +312,7 @@ const processGlobalDeaths = async () => { record.timeSeriesDaily[record.timeSeriesDaily.length - 1].value : 0; record.timeSeriesMonthly = monthlyTotals; + record.rollingAverageDaily = getRollingAverage(record); record.state = record['Province/State']; record.country = record['Country/Region']; diff --git a/tmpl/master.pug b/tmpl/master.pug index 5e5674e..5eb026c 100644 --- a/tmpl/master.pug +++ b/tmpl/master.pug @@ -74,6 +74,7 @@ html function makeSparkline(id, data) { const canvas = document.getElementById(id); const maxValue = data.reduce((max, value) => Math.max(max, value), 0); + const max = maxValue > 0 ? Math.pow(10, Math.ceil(Math.log10(maxValue))) : 0 const chart = new Chart(canvas.getContext('2d'), { type: 'line', data: { @@ -107,7 +108,7 @@ html precision: 0, beginAtZero: true, min: 0, - max: maxValue > 0 ? Math.pow(10, Math.ceil(Math.log10(maxValue))) : 0, + max: Math.max(max, 2), // this is necessary for some reason callback: value => Number(value.toString()), } }, @@ -388,7 +389,7 @@ html script. makeSparkline( "sparkline-#{i}", - #{JSON.stringify(item.timeSeriesDaily.slice(-14).map(x => x.delta))}, + #{JSON.stringify(item.rollingAverageDaily.slice(-14).map(x => x.delta))} );