use rolling average for trend line
This commit is contained in:
parent
0fe3817c20
commit
b86ac75ffd
@ -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'];
|
||||
|
@ -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))}
|
||||
);
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user