Commit 15b633c4 authored by Michał Woźniak's avatar Michał Woźniak
Browse files

added per-million display

parent 8ebbc5da
Pipeline #136 passed with stage
in 0 seconds
......@@ -28,7 +28,7 @@ Remember this when somebody tells you again that they need Google Fonts ([nope](
Some improvements have been suggested, no promises if and when they get implemented!
- normalize to population, show cases per million
- ~~normalize to population, show cases per million~~
- make the new daily cases graph a rolling average with control over how many days/datapoints
- chart global cases
- chart cases requiring intensive medical care
......
......@@ -1066,6 +1066,12 @@ let updateChartData = (siteSelect) => {
to_chart.data = filtered_data.map(row => row.delta)
}
// are we in for per-million values?
if (document.querySelector('input[type=radio][name=chart-values]:checked').value === "per-million") {
population_ratio = siteData[siteSelect.value].population / 1000000
to_chart.data = to_chart.data.map(row => Math.round(row / population_ratio))
}
// assign the data to the chart
theChart.data.datasets[siteSelect.siteNo + 3] = to_chart
......@@ -1215,7 +1221,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{
document.querySelectorAll('input[type=radio][name=chart-type]').forEach((node)=>{
node.addEventListener('change', updateChartSettings)
})
document.querySelectorAll('input[type=radio][name=chart-cases], input[type=radio][name=chart-start]').forEach((node)=>{
document.querySelectorAll('input[type=radio][name=chart-cases], input[type=radio][name=chart-start], input[type=radio][name=chart-values]').forEach((node)=>{
node.addEventListener('change', (e)=>{
for (select_index=0; select_index<sitesSelects.length; select_index++) {
updateChartData(sitesSelects[select_index])
......
......@@ -265,6 +265,13 @@
<input type="radio" id="chart-cases-new" name="chart-cases" value="new" >
<label for="chart-cases-new">new</label>
</div>
<div class="chart-config-group">
<p>Values:</p>
<input type="radio" id="chart-values-absolute" name="chart-values" value="absolute" checked="checked"/>
<label for="chart-values-absolute">absolute</label>
<input type="radio" id="chart-values-per-million" name="chart-values" value="per-million" >
<label for="chart-values-per-million">per 1M</label>
</div>
<div class="chart-config-group">
<p>Start from:</p>
<input type="radio" id="chart-start-first" name="chart-start" value="1"/>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment