covid19/tmpl/country.pug

78 lines
3.0 KiB
Plaintext
Raw Normal View History

2020-04-27 03:04:16 +00:00
extends ./master.pug
block main
h2
a.float-right(href="/" style="font-size: 50%") ◀ All Countries
=data.name
2020-04-27 23:10:38 +00:00
+heroChart
2020-04-27 03:04:16 +00:00
2020-04-27 15:54:26 +00:00
div#table.table-responsive: table.table.table-sm.table-hover.table-bordered
2020-04-27 03:04:16 +00:00
thead: tr
th #
2020-04-27 15:54:26 +00:00
th(data-col="name"): +sortableLinks("name") State/Province
2020-04-28 03:02:31 +00:00
if data.name === 'United States'
th.text-center(data-col="population"): +sortableLinks("population") Population
2020-04-27 15:54:26 +00:00
th.text-center(data-col="total"): +sortableLinks("total") Deaths
2020-04-28 03:02:31 +00:00
if data.name === 'United States'
th.text-center(data-col="million"): +sortableLinks("million") …/1M
2020-04-27 15:54:26 +00:00
th.text-center.sorted(data-col="yesterday"): +sortableLinks("yesterday") …since yesterday
th.text-center(data-col="week"): +sortableLinks("week") …since last week
th.text-center(data-col="month"): +sortableLinks("month") …month-to-date
2020-04-28 03:02:31 +00:00
th.text-center(data-col="growth"): +sortableLinks("growth") …growth rate
2020-04-27 15:54:26 +00:00
th.text-center Last 14 days
-
data.states.sort((a, b) => {
const yesterdayA = a.timeSeriesDaily[a.timeSeriesDaily.length - 1].delta;
const yesterdayB = b.timeSeriesDaily[b.timeSeriesDaily.length - 1].delta;
if (yesterdayA === yesterdayB) {
return a.name && b.name ? a.name.localeCompare(b.name) : -1;
}
return yesterdayA < yesterdayB ? 1 : -1;
});
2020-04-27 03:04:16 +00:00
tbody: each item, i in data.states
- const yesterday = item.timeSeriesDaily[item.timeSeriesDaily.length - 1].delta || 0;
- const lastWeek = item.timeSeriesDaily[item.timeSeriesDaily.length - 1].value - item.timeSeriesDaily[item.timeSeriesDaily.length - 7].value;
- const lastMonth = item.timeSeriesMonthly[item.timeSeriesMonthly.length - 1].delta || 0;
2020-04-28 03:02:31 +00:00
tr(
id=("row-" + item.safeName)
data-name=item.name
data-population=item.population
data-total=item.total
data-million=item.deathsPerMillion
data-yesterday=yesterday
data-week=lastWeek
data-month=lastMonth
data-growth=item.deathGrowthRate
)
2020-04-27 03:04:16 +00:00
td.sort-order= i + 1
td
if item.name
if item.counties && item.counties.length
a(href=("/countries/" + item.countrySafeName + "-" + item.safeName + ".html"))= item.name
else
= item.name
else if item.state
2020-04-27 03:04:16 +00:00
= item.state
2020-04-27 15:54:26 +00:00
else if item.country === 'United States'
2020-04-27 03:04:16 +00:00
em.text-muted All #{item.country}
else
em.text-muted Other #{item.country}
2020-04-28 03:02:31 +00:00
if data.name === 'United States'
td.text-right: +formatNumber(item.population)
2020-04-27 03:04:16 +00:00
td.text-right: +formatNumber(item.total)
2020-04-28 03:02:31 +00:00
if data.name === 'United States'
td.text-right: +formatNumber(Math.round(item.deathsPerMillion))
2020-04-27 15:54:26 +00:00
td.text-right.sorted: +formatNumber(yesterday)
2020-04-27 03:04:16 +00:00
td.text-right: +formatNumber(lastWeek)
td.text-right: +formatNumber(lastMonth)
2020-04-28 03:02:31 +00:00
td.text-right= Number(item.deathGrowthRate * 100).toFixed(2) + '%'
2020-04-27 03:04:16 +00:00
td
2020-04-27 15:54:26 +00:00
canvas.mx-auto(id="sparkline-" + i width="200" height="50")
2020-04-27 03:04:16 +00:00
script.
2020-04-27 15:54:26 +00:00
makeSparkline(
"sparkline-#{i}",
#{JSON.stringify(item.timeSeriesDaily.slice(-14).map(x => x.value))},
);