Skip to content

Commit

Permalink
Update average calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
janslifka committed Mar 3, 2023
1 parent 6fbe2b1 commit ad7960f
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -107,10 +107,15 @@ <h2>Positive tests over time</h2>

for (let i = 0; i < values.length; i++) {
let sum = 0
let count = 0

for (let j = i - 6; j <= i; j++) {
sum += j < 0 ? values[0] : values[j]
if (j >= 0) {
sum += values[j]
count++
}
}
averageData.push(Math.round(sum / 7))
averageData.push(Math.round(sum / count))
}

const ctx = document.getElementById('chart')
Expand Down

0 comments on commit ad7960f

Please sign in to comment.