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

menu-button-recovered added; buttons now set best chart settings for them

parent 26b064d0
Pipeline #175 passed with stage
in 1 second
......@@ -1619,6 +1619,9 @@ document.addEventListener('DOMContentLoaded', (e)=>{
}
})
// compare functions for sort()
// used in "Load 6 sites..." menu buttons handler
let menu_compare_functions = {
"site-menu-button-rate": (a, b)=>{
// make the formulas easier on the eyes
......@@ -1648,6 +1651,13 @@ document.addEventListener('DOMContentLoaded', (e)=>{
// return deaths comparison
return bdata[bdata.length-1].deaths - adata[adata.length-1].deaths;
},
"site-menu-button-recovered": (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].recovered - adata[adata.length-1].recovered;
},
"site-menu-button-active-drop": (a, b)=>{
// make the formulas easier on the eyes
var adata = siteData[a].data
......@@ -1665,17 +1675,48 @@ document.addEventListener('DOMContentLoaded', (e)=>{
}
// return new_active comparison
return adata[adata.length-1].new_active - bdata[bdata.length-1].new_active;
}
}
// chart setting functions
// used in "Load 6 sites..." menu buttons handler
let menu_chart_settings = {
"site-menu-button-rate": ()=>{
document.getElementById('chart-data-confirmed').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-recoveries": (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].recovered - adata[adata.length-1].recovered;
"site-menu-button-percentage": ()=>{
document.getElementById('chart-data-confirmed').checked = true
document.getElementById('chart-cases-cumulative').checked = true
document.getElementById('chart-values-per-million').checked = true
document.getElementById('chart-type-logarithmic').checked = true
},
"site-menu-button-deaths": ()=>{
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
document.getElementById('chart-cases-cumulative').checked = true
document.getElementById('chart-values-absolute').checked = true
document.getElementById('chart-type-logarithmic').checked = true
},
"site-menu-button-active-drop": ()=>{
document.getElementById('chart-data-active').checked = true
document.getElementById('chart-cases-new').checked = true
document.getElementById('chart-values-absolute').checked = true
document.getElementById('chart-type-linear').checked = true
}
}
//
// handle the "Load 6 sites..." menu buttons
document.querySelectorAll('#internal-main-menu-container input[type=button]').forEach((node)=>{
// add a listener
node.addEventListener('click', (e)=>{
......@@ -1708,7 +1749,11 @@ document.addEventListener('DOMContentLoaded', (e)=>{
return site.toLowerCase().replace(/[^a-z]/g, '-')
})
.join(',')
// set the chart settings to what is best to view the particular data
if (e.target.id in menu_chart_settings) {
menu_chart_settings[e.target.id]()
}
// TODO: we need to find a better way to do this
window.location.hash = '#' + sites
})
......
......@@ -388,7 +388,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-recoveries" value="most recoveries"/>
<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>
</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