2020-04-27 08:54:26 -07:00

224 lines
8.8 KiB
HTML

<!DOCTYPE html><html><head><title>Peru | Covid-19</title><meta charset="utf8"><link rel="stylesheet" href="/bootstrap.css"><script src="/Chart.bundle.js"></script><style>table td {
vertical-align: middle !important;
}
th.sorted, td.sorted {
background-color: #e0eefd;
}
.table-sm {
font-size: 80%;
}
</style><script>function makeSparkline(id, data) {
const canvas = document.getElementById(id);
const chart = new Chart(canvas.getContext('2d'), {
type: 'line',
data: {
labels: [1, 2, 3, 4, 5, 6, 7, 8, 10, 11, 12, 13, 14],
datasets: [{ data: data }],
},
options: {
responsive: false,
legend: {
display: false,
},
elements: {
line: {
borderColor: '#000000',
borderWidth: 1,
},
point: {
radius: 0,
},
},
tooltips: {
enabled: false,
},
scales: {
yAxes: [
{
display: false,
ticks: {
precision: 0,
beginAtZero: true,
}
},
],
xAxes: [
{
display: false,
},
],
}
}
});
}
function makeHeroChart(id, title, labels, totalDeaths, newDeaths) {
const canvas = document.getElementById(id);
const chart = new Chart(canvas.getContext('2d'), {
type: 'line',
data: {
labels: labels,
datasets: [
{
label: 'Total Deaths',
data: totalDeaths,
fill: true,
borderColor: 'rgb(196, 64, 64)',
borderWidth: 1,
backgroundColor: 'rgba(196, 128, 128, 0.25)',
},
{
label: 'New Deaths',
data: newDeaths,
fill: true,
borderColor: 'rgb(64, 64, 64)',
borderWidth: 1,
backgroundColor: 'rgba(128, 128, 128, 0.75)',
}
],
},
options: {
responsive: false,
title: {
display: true,
position: 'top',
text: title,
},
tooltips: {
intersect: false,
position: 'nearest',
axis: 'x',
},
scales: {
yAxes: [
{
display: true,
ticks: {
precision: 0,
beginAtZero: true,
}
},
],
xAxes: [
{
display: true,
},
],
}
}
});
}</script></head><body><div class="container"><h1>Covid-19 Data</h1><p class="text-muted"><em>Data from <a href="https://github.com/CSSEGISandData/COVID-19">Johns Hopkins CSSE</a>.
This page generated from latest data as of 2020-04-27T15:51:44.105Z.
</em></p><div class="main-content"><h2><a class="float-right" href="/" style="font-size: 50%">◀ All Countries</a>Peru</h2><div class="card mb-4"><div class="card-body"><canvas class="mx-auto" id="main-chart" width="800" height="450"></canvas><script>makeHeroChart(
'main-chart',
"Peru",
["2020-01-22","2020-01-23","2020-01-24","2020-01-25","2020-01-26","2020-01-27","2020-01-28","2020-01-29","2020-01-30","2020-01-31","2020-02-01","2020-02-02","2020-02-03","2020-02-04","2020-02-05","2020-02-06","2020-02-07","2020-02-08","2020-02-09","2020-02-10","2020-02-11","2020-02-12","2020-02-13","2020-02-14","2020-02-15","2020-02-16","2020-02-17","2020-02-18","2020-02-19","2020-02-20","2020-02-21","2020-02-22","2020-02-23","2020-02-24","2020-02-25","2020-02-26","2020-02-27","2020-02-28","2020-02-29","2020-03-01","2020-03-02","2020-03-03","2020-03-04","2020-03-05","2020-03-06","2020-03-07","2020-03-08","2020-03-09","2020-03-10","2020-03-11","2020-03-12","2020-03-13","2020-03-14","2020-03-15","2020-03-16","2020-03-17","2020-03-18","2020-03-19","2020-03-20","2020-03-21","2020-03-22","2020-03-23","2020-03-24","2020-03-25","2020-03-26","2020-03-27","2020-03-28","2020-03-29","2020-03-30","2020-03-31","2020-04-01","2020-04-02","2020-04-03","2020-04-04","2020-04-05","2020-04-06","2020-04-07","2020-04-08","2020-04-09","2020-04-10","2020-04-11","2020-04-12","2020-04-13","2020-04-14","2020-04-15","2020-04-16","2020-04-17","2020-04-18","2020-04-19","2020-04-20","2020-04-21","2020-04-22","2020-04-23","2020-04-24","2020-04-25","2020-04-26"],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,5,5,5,7,9,9,11,16,18,24,30,38,55,61,73,83,92,107,121,138,169,181,193,216,230,254,274,300,348,400,445,484,530,572,634,700,728],
[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,2,0,0,2,2,0,2,5,2,6,6,8,17,6,12,10,9,15,14,17,31,12,12,23,14,24,20,26,48,52,45,39,46,42,62,66,28],
);
</script></div></div><div class="table-responsive" id="table"><table class="table table-sm table-hover table-bordered"><thead><tr><th>#</th><th data-col="name"><div class="d-inline-flex"><span class="sortables mr-2 d-inline-flex flex-column" style="font-size: 50%"><a href="#sort:name:asc"></a><a href="#sort:name:desc"></a></span><span>State/Province</span></div></th><th class="text-center" data-col="total"><div class="d-inline-flex"><span class="sortables mr-2 d-inline-flex flex-column" style="font-size: 50%"><a href="#sort:total:asc"></a><a href="#sort:total:desc"></a></span><span>Deaths</span></div></th><th class="text-center sorted" data-col="yesterday"><div class="d-inline-flex"><span class="sortables mr-2 d-inline-flex flex-column" style="font-size: 50%"><a href="#sort:yesterday:asc"></a><a href="#sort:yesterday:desc"></a></span><span>&hellip;since yesterday</span></div></th><th class="text-center" data-col="week"><div class="d-inline-flex"><span class="sortables mr-2 d-inline-flex flex-column" style="font-size: 50%"><a href="#sort:week:asc"></a><a href="#sort:week:desc"></a></span><span>&hellip;since last week</span></div></th><th class="text-center" data-col="month"><div class="d-inline-flex"><span class="sortables mr-2 d-inline-flex flex-column" style="font-size: 50%"><a href="#sort:month:asc"></a><a href="#sort:month:desc"></a></span><span>&hellip;month-to-date</span></div></th><th class="text-center">Last 14 days</th></tr></thead><tbody><tr id="row-undefined" data-total="728" data-yesterday="28" data-week="283" data-month="698"><td class="sort-order">1</td><td><em class="text-muted">Other Peru</em></td><td class="text-right">728</td><td class="text-right sorted">28</td><td class="text-right">283</td><td class="text-right">698</td><td><canvas class="mx-auto" id="sparkline-0" width="200" height="50"></canvas><script>makeSparkline(
"sparkline-0",
[216,230,254,274,300,348,400,445,484,530,572,634,700,728],
);</script></td></tr></tbody></table></div></div></div><script>(function() {
const table = document.getElementById('table');
const headerRow = table.querySelector('thead tr');
const headers = [].slice.call(headerRow.querySelectorAll('th'));
const tbody = table.querySelector('tbody');
const allRows = [].slice.call(tbody.querySelectorAll('tbody tr'));
const resortTable = (col) => {
let nextChild = null;
const highlightedIndex = headers.findIndex(cell => cell.getAttribute('data-col') === col);
console.log(col, highlightedIndex);
headers.forEach((cell, i) => {
if (i !== highlightedIndex) {
cell.classList.remove('sorted');
} else {
cell.classList.add('sorted');
}
});
for (let i = allRows.length - 1; i >= 0; i--) {
const row = allRows[i];
if (!row) {
continue;
}
const cells = [].slice.call(row.querySelectorAll('td'));
cells.forEach((cell, i) => {
if (i !== highlightedIndex) {
cell.classList.remove('sorted');
} else {
cell.classList.add('sorted');
}
});
if (row === nextChild) {
continue;
}
tbody.insertBefore(row, nextChild);
row.querySelector('.sort-order').textContent = (i + 1).toString();
nextChild = row;
}
};
const handleSort = (value, dir) => {
const newSortDir = dir === 'desc' ? 'desc' : 'asc';
const sortByNumberThenName = (attr) => {
allRows.sort((a, b) => {
const aValue = Number(a.getAttribute('data-' + attr));
const bValue = Number(b.getAttribute('data-' + attr));
if (aValue === bValue) {
const aName = a.getAttribute('data-name');
const bName = b.getAttribute('data-name');
return aName && bName ? aName.localeCompare(bName) : 0;
}
return aValue < bValue ?
(newSortDir === 'asc' ? -1 : 1) :
(newSortDir === 'asc' ? 1 : -1);
});
resortTable(value);
};
switch (value) {
case 'name':
allRows.sort((a, b) => {
const aName = a.getAttribute('data-name');
const bName = b.getAttribute('data-name');
if (!aName || !bName) {
return -1;
}
if (newSortDir === 'asc') {
return aName.localeCompare(bName);
}
return bName.localeCompare(aName);
});
resortTable('name');
break;
case 'total':
sortByNumberThenName('total');
break;
case 'yesterday':
sortByNumberThenName('yesterday');
break;
case 'week':
sortByNumberThenName('week');
break;
case 'month':
sortByNumberThenName('month');
break;
}
};
const handleHash = (hash) => {
const sortValue = hash.replace(/^#sort:/, '').split(':');
handleSort(sortValue[0], sortValue[1]);
};
window.addEventListener('hashchange', () => {
handleHash(window.location.hash);
});
handleHash(window.location.hash);
}());</script></body></html>