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

new <dataset> -> delta <dataset>

parent c72a877c
......@@ -676,37 +676,37 @@ let getCovidData = () => {
*/
let calculateDeltas = (data) => {
// perhaps we have that data already?
if ("new_confirmed" in data.data[0]) {
if ("delta_confirmed" in data.data[0]) {
return data;
}
// calculate the deltas
data.data = data.data.map((cur, i, d)=>{
if (i==0) {
cur.new_confirmed = 0;
cur.new_recovered = 0;
cur.new_deaths = 0;
cur.delta_confirmed = 0;
cur.delta_recovered = 0;
cur.delta_deaths = 0;
cur.active = 0;
cur.new_active = 0;
cur.delta_active = 0;
cur.cfr = 0
cur.new_cfr = 0
cur.delta_cfr = 0
} else {
cur.new_confirmed = cur.confirmed - d[i-1].confirmed
cur.new_recovered = cur.recovered - d[i-1].recovered
cur.new_deaths = cur.deaths - d[i-1].deaths
cur.delta_confirmed = cur.confirmed - d[i-1].confirmed
cur.delta_recovered = cur.recovered - d[i-1].recovered
cur.delta_deaths = cur.deaths - d[i-1].deaths
var removed = cur.recovered + cur.deaths
cur.active = cur.confirmed - removed
cur.new_active = cur.active - d[i-1].active
cur.delta_active = cur.active - d[i-1].active
// case fatality rate
if (removed > 0) {
cur.cfr = cur.deaths / removed
cur.new_cfr = cur.cfr - d[i-1].cfr
cur.delta_cfr = cur.cfr - d[i-1].cfr
} else {
cur.cfr = 0
cur.new_cfr = 0
cur.delta_cfr = 0
}
}
return cur;
......@@ -1380,7 +1380,7 @@ let updateChartData = (siteSelect) => {
to_chart.data = filtered_data.map(row => row[dataset])
// use new cases count
} else {
to_chart.data = filtered_data.map(row => row[`new_${dataset}`])
to_chart.data = filtered_data.map(row => row[`delta_${dataset}`])
}
// are we in for per-million values?
......@@ -1882,7 +1882,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// make the formulas easier on the eyes
var adata = siteData[a].data
var bdata = siteData[b].data
// we can assume active is there if new_active is, right?.. right?..
// we can assume active is there if delta_active is, right?.. right?..
if (! ("cfr" in adata[adata.length - 1]) ) {
if ( (adata[adata.length - 1].recovered + adata[adata.length - 1].deaths) === 0) {
adata[adata.length - 1].cfr = 0
......@@ -1897,7 +1897,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{
bdata[bdata.length - 1].cfr = bdata[bdata.length - 1].deaths / (bdata[bdata.length - 1].recovered + bdata[bdata.length - 1].deaths)
}
}
// return new_active comparison
// return delta_active comparison
return bdata[bdata.length-1].cfr - adata[adata.length-1].cfr;
},
"site-menu-button-recovered": (a, b)=>{
......@@ -1911,19 +1911,19 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// make the formulas easier on the eyes
var adata = siteData[a].data
var bdata = siteData[b].data
// we can assume active is there if new_active is, right?.. right?..
if (! ("new_active" in adata[adata.length - 1]) ) {
// we can assume active is there if delta_active is, right?.. right?..
if (! ("delta_active" in adata[adata.length - 1]) ) {
adata[adata.length - 1].active = adata[adata.length - 1].confirmed - (adata[adata.length - 1].recovered + adata[adata.length - 1].deaths)
adata[adata.length - 2].active = adata[adata.length - 2].confirmed - (adata[adata.length - 2].recovered + adata[adata.length - 2].deaths)
adata[adata.length - 1].new_active = adata[adata.length - 1].active - adata[adata.length - 2].active
adata[adata.length - 1].delta_active = adata[adata.length - 1].active - adata[adata.length - 2].active
}
if (! ("new_active" in bdata[bdata.length - 1]) ) {
if (! ("delta_active" in bdata[bdata.length - 1]) ) {
bdata[bdata.length - 1].active = bdata[bdata.length - 1].confirmed - (bdata[bdata.length - 1].recovered + bdata[bdata.length - 1].deaths)
bdata[bdata.length - 2].active = bdata[bdata.length - 2].confirmed - (bdata[bdata.length - 2].recovered + bdata[bdata.length - 2].deaths)
bdata[bdata.length - 1].new_active = bdata[bdata.length - 1].active - bdata[bdata.length - 2].active
bdata[bdata.length - 1].delta_active = bdata[bdata.length - 1].active - bdata[bdata.length - 2].active
}
// return new_active comparison
return adata[adata.length-1].new_active - bdata[bdata.length-1].new_active;
// return delta_active comparison
return adata[adata.length-1].delta_active - bdata[bdata.length-1].delta_active;
}
}
......@@ -1970,7 +1970,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{
},
"site-menu-button-active-drop": ()=>{
document.getElementById('chart-data-active').checked = true
document.getElementById('chart-cases-new').checked = true
document.getElementById('chart-cases-delta').checked = true
document.getElementById('chart-values-absolute').checked = true
document.getElementById('chart-type-linear').checked = true
}
......
......@@ -326,13 +326,13 @@
.chart-config-container input#chart-data-active:checked ~ .chart-config-group label[for=chart-data-active],
.chart-config-container input#chart-data-cfr:checked ~ .chart-config-group label[for=chart-data-cfr],
.chart-config-container input#chart-cases-cumulative:checked ~ .chart-config-group label[for=chart-cases-cumulative],
.chart-config-container input#chart-cases-new:checked ~ .chart-config-group label[for=chart-cases-new],
.chart-config-container input#chart-cases-delta:checked ~ .chart-config-group label[for=chart-cases-delta],
.chart-config-container input#chart-data-active:not(:checked) ~ input#chart-data-cfr:not(:checked) ~ input#chart-type-logarithmic:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-active:not(:checked) ~ input#chart-cases-new:not(:checked) ~ input#chart-type-logarithmic:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-cfr:not(:checked) ~ input#chart-cases-new:not(:checked) ~ input#chart-type-logarithmic:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-active:not(:checked) ~ input#chart-cases-delta:not(:checked) ~ input#chart-type-logarithmic:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-cfr:not(:checked) ~ input#chart-cases-delta:not(:checked) ~ input#chart-type-logarithmic:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-type-linear:checked ~ .chart-config-group label[for=chart-type-linear],
.chart-config-container input#chart-data-active:checked ~ input#chart-cases-new:checked ~ .chart-config-group label[for=chart-type-linear],
.chart-config-container input#chart-data-cfr:checked ~ input#chart-cases-new:checked ~ .chart-config-group label[for=chart-type-linear],
.chart-config-container input#chart-data-active:checked ~ input#chart-cases-delta:checked ~ .chart-config-group label[for=chart-type-linear],
.chart-config-container input#chart-data-cfr:checked ~ input#chart-cases-delta:checked ~ .chart-config-group label[for=chart-type-linear],
.chart-config-container input#chart-values-absolute:checked ~ .chart-config-group label[for=chart-values-absolute],
.chart-config-container input#chart-data-cfr:checked ~ .chart-config-group label[for=chart-values-absolute],
.chart-config-container input#chart-data-cfr:not(:checked) ~ input#chart-values-per-million:checked ~ .chart-config-group label[for=chart-values-per-million],
......@@ -345,8 +345,8 @@
color:black;
box-shadow: 0px 0px 2px springgreen;
}
.chart-config-container input#chart-data-active:checked ~ input#chart-cases-new:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-cfr:checked ~ input#chart-cases-new:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-active:checked ~ input#chart-cases-delta:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-cfr:checked ~ input#chart-cases-delta:checked ~ .chart-config-group label[for=chart-type-logarithmic],
.chart-config-container input#chart-data-cfr:checked ~ .chart-config-group label[for=chart-values-per-million] {
opacity:0.5;
pointer-events: none;
......@@ -427,7 +427,7 @@
.chart-config-group.chart-average {
display:none;
}
.chart-config-container input#chart-cases-new:checked ~ .chart-config-group.chart-average {
.chart-config-container input#chart-cases-delta:checked ~ .chart-config-group.chart-average {
display:flex;
}
.chart-config-container #chart-average {
......@@ -499,7 +499,7 @@
<input type="radio" id="chart-data-active" name="chart-data" value="active"/>
<input type="radio" id="chart-data-cfr" name="chart-data" value="cfr"/>
<input type="radio" id="chart-cases-cumulative" name="chart-cases" value="cumulative" checked="checked"/>
<input type="radio" id="chart-cases-new" name="chart-cases" value="new"/>
<input type="radio" id="chart-cases-delta" name="chart-cases" value="new"/>
<input type="radio" id="chart-type-logarithmic" name="chart-type" value="logarithmic" checked="checked"/>
<input type="radio" id="chart-type-linear" name="chart-type" value="linear"/>
<input type="radio" id="chart-values-absolute" name="chart-values" value="absolute" checked="checked"/>
......@@ -526,7 +526,7 @@
<div class="chart-config-group">
<p><span class="cases-cases">Cases</span><span class="cases-recoveries">Recoveries</span><span class="cases-deaths">Deaths</span><span class="cases-chart">Chart</span>:</p>
<label for="chart-cases-cumulative"><span class="values-cumulative">cumulative</span><span class="values-count">count</span><span class="values-values">values</span></label>
<label for="chart-cases-new"><span class="delta-new">new</span><span class="delta-change">change</span></label>
<label for="chart-cases-delta"><span class="delta-new">new</span><span class="delta-change">change</span></label>
</div>
<div class="chart-config-group chart-average">
<p>Average over:</p>
......
Markdown is supported
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