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

mortality is actually death-to-case ratio; also, added a load-six-sites menu...

mortality is actually death-to-case ratio; also, added a load-six-sites menu button for death-to-case
parent 92ef7517
Pipeline #178 passed with stage
in 1 second
......@@ -621,13 +621,13 @@ let getCovidData = () => {
siteData['Global'].source_title = "pomber / covid19"
var cleaned_data = siteData['Global'].data.slice(-1)[0]
cleaned_data.mortality = cleaned_data.deaths / cleaned_data.confirmed
cleaned_data.death_to_case = cleaned_data.deaths / cleaned_data.confirmed
console.log(`+-- got global covid data:`
+ `\n date : ${cleaned_data.date}`
+ `\n confirmed : ${cleaned_data.confirmed}`
+ `\n deaths : ${cleaned_data.deaths}`
+ `\n recovered : ${cleaned_data.recovered}`
+ `\n mortality : ${cleaned_data.mortality}`)
+ `\n date : ${cleaned_data.date}`
+ `\n confirmed : ${cleaned_data.confirmed}`
+ `\n deaths : ${cleaned_data.deaths}`
+ `\n recovered : ${cleaned_data.recovered}`
+ `\n death-to-case : ${cleaned_data.death_to_case}`)
// hey we can get countries / locations / infection sites list from this too!
Object
......@@ -1672,6 +1672,13 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// return deaths comparison
return bdata[bdata.length-1].deaths - adata[adata.length-1].deaths;
},
"site-menu-button-death-to-case": (a, b)=>{
// make the formulas easier on the eyes
var adata = siteData[a].data
var bdata = siteData[b].data
// return deaths comparison
return (bdata[bdata.length-1].deaths / bdata[bdata.length-1].confirmed) - (adata[adata.length-1].deaths / adata[adata.length-1].confirmed);
},
"site-menu-button-recovered": (a, b)=>{
// make the formulas easier on the eyes
var adata = siteData[a].data
......@@ -1721,6 +1728,12 @@ document.addEventListener('DOMContentLoaded', (e)=>{
document.getElementById('chart-values-absolute').checked = true
document.getElementById('chart-type-logarithmic').checked = true
},
"site-menu-button-death-to-case": ()=>{
document.getElementById('chart-data-deaths').checked = true
document.getElementById('chart-cases-cumulative').checked = true
document.getElementById('chart-values-absolute').checked = true
document.getElementById('chart-type-logarithmic').checked = true
},
"site-menu-button-recovered": ()=>{
console.log('site-menu-button-recovered')
document.getElementById('chart-data-recovered').checked = true
......@@ -1790,7 +1803,7 @@ document.addEventListener('DOMContentLoaded', (e)=>{
document.querySelector('#covid-stats > #confirmed > .value').innerHTML = data.confirmed
document.querySelector('#covid-stats > #deaths > .value').innerHTML = data.deaths
document.querySelector('#covid-stats > #recovered > .value').innerHTML = data.recovered
document.querySelector('#covid-stats > #mortality > .value').innerHTML = "~" + Math.round(data.mortality * 10000) / 100 + '%'
document.querySelector('#covid-stats > #death-to-case > .value').innerHTML = "~" + Math.round(data.death_to_case * 10000) / 100 + '%'
// update the interface
document.querySelector('input[type=date][name=chart-start-date]').min = siteData['Global'].data[0].date.replace(/-([0-9](?![0-9]))/g, '-0$1')
......
......@@ -378,7 +378,7 @@
<div id="confirmed"><span class="label">Confirmed cases:</span> <span class="value">(loading...)</span></div>
<div id="deaths"><span class="label">Deaths:</span> <span class="value">(loading...)</span></div>
<div id="recovered"><span class="label">Recovered:</span> <span class="value">(loading...)</span></div>
<div id="mortality"><span class="label">Mortality rate:</span> <span class="value">(loading...)</span></div>
<div id="death-to-case"><span class="label">Death-to-case ratio:</span> <span class="value">(loading...)</span></div>
</div>
<div class="sources"><a href="https://github.com/CSSEGISandData/COVID-19">source</a></div>
<div id="main-menu-container">
......@@ -387,6 +387,7 @@
<input type="button" id="site-menu-button-rate" value="largest growth rate"/>
<input type="button" id="site-menu-button-percentage" value="highest percentage of population infected"/>
<input type="button" id="site-menu-button-deaths" value="most deaths"/>
<input type="button" id="site-menu-button-death-to-case" value="highest death-to-case ratio"/>
<input type="button" id="site-menu-button-recovered" value="most recoveries"/>
<input type="button" id="site-menu-button-active-drop" value="greatest daily drop of number of active cases"/>
</div>
......
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