forked from code4sabae/covid19
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfukui.html
196 lines (184 loc) · 6.35 KB
/
fukui.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
<!DOCTYPE html><html><head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0"/>
<link rel="apple-touch-icon" href="fukui_icon.png"/>
<meta property="og:image" content="fukui_ogp.png"/>
<meta name="format-detection" content="telephone=no"/>
<title>COVID-19 Fukui - 福井県 新型コロナウイルス対策ダッシュボード</title>
<script src="https://fukuno.jig.jp/app/csv/lib/fukuno.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.js"></script>
<script>"use strict"
const url = 'https://app.sabae.cc/api/covid19fukui.json'
const update = async function() {
//const url = "https://raw.githubusercontent.com/tokyo-metropolitan-gov/covid19/master/data/data.json" // Tokyo
//const url = 'https://raw.githubusercontent.com/codeforsapporo/covid19/master/data/data.json' // Hokkaido
const data = await (await fetch(url)).json()
console.log(data)
const calcSum = (data) => data.reduce((acc, val) => acc + parseInt(val['小計']), 0)
/*
const calcSum = function(data) {
let sum = 0
for (const d of data) {
sum += d['小計']
}
return sum
}
*/
const ncontacts = 0 // calcSum(data.contacts.data)
const nquerents = 0 // calcSum(data.querents.data)
const npatiants = data.summary.n_patients
const ndischarges = 0 // data.discharges.data.length
const ninspections = data.summary.n_inspections
const ndeath = data.summary.n_death
const nlight = data.summary.n_light
const nheavy = data.summary.n_heavy
const nexit = data.summary.n_exit
const npatients_c = nlight + nheavy
const npcrperday = data.summary.n_capacity_pcr_per_day
const nbed = data.summary.n_capacity_bed
table_c.innerHTML = `
<table>
<tr><td>現在患者数(入院中)</td><td>${addComma(npatients_c)}人</td></tr>
<tr><td>感染症病床数</td><td>${nbed}床</td></tr>
<tr><td>感染症病床使用率(現在患者数/感染症病床数)</td><td>${fixfloat(npatients_c * 100 / nbed, 2)}%</td></tr>
<tr><td>陽性患者数</td><td>${addComma(npatiants)}人</td></tr>
<tr><td>検査実施人数</td><td>${addComma(ninspections)}人</td></tr>
<tr><td>陽性率(陽性患者数/検査実施人数)</td><td>${fixfloat(npatiants * 100 / ninspections, 2)}%</td></tr>
<tr><td>1日当たりPCR検査可能件数</td><td>${npcrperday}件</td></tr>
<tr><td>死亡数(死亡数/陽性患者数)</td><td>${addComma(ndeath)}人(${fixfloat(ndeath * 100 / npatiants, 2)}%)</td></tr>
<tr><td>重症(死亡数/陽性患者数)</td><td>${addComma(nheavy)}人(${fixfloat(nheavy * 100 / npatiants, 2)}%)</td></tr>
<tr><td>軽症・中等症(軽症・中等症数/陽性患者数)</td><td>${addComma(nlight)}人(${fixfloat(nlight * 100 / npatiants, 2)}%)</td></tr>
<tr><td>退院数(退院数/陽性患者数)</td><td>${addComma(nexit)}人(${fixfloat(nexit * 100 / npatiants, 2)}%)</td></tr>
<!--
<tr><td>新型コロナコールセンター相談件数</td><td>${addComma(ncontacts)}件</td></tr>
<tr><td>帰国者・接触者電話相談センター相談件数</td><td>${addComma(nquerents)}件</td></tr>
-->
<tr><td>最終更新日時</td><td>${data.lastUpdate}</td></tr>
</table>
`
// console.log(ncontacts, nquerents, npatiants, npatiants2, ndischarges, ndischarges2)
dump(data)
new Chart(chart, {
type: 'pie',
data: {
labels: [ "現在患者数", "空き病床数(推測)" ],
datasets: [{
backgroundColor: [ 'red', '#ccc' ],
data: [ npatients_c, nbed - npatients_c ],
}]
},
options: {
title: {
display: true,
text: '感染症病床使用率(参考)'
}
}
})
}
window.onload = update
setInterval(update, 10 * 60 * 1000) // 10min
</script>
<style>
body {
font-family: sans-serif;
margin: 0;
word-wrap: break-word;
--main-color: #152876;
text-align: center;
}
h1 {
margin: 0;
padding: .3em;
background-color: var(--main-color);
color: white;
font-size: 8vw;
text-align: center;
}
.subtitle {
text-align: center;
margin: 0;
padding: .3em;
background-color: var(--main-color);
color: white;
font-size: 3vw;
}
#main {
text-align: center;
}
#table_c {
display: inline-block;
}
#table_c, #link {
text-align: center;
}
table {
display: inline-block;
margin: .5em;
border-collapse: collapse;
}
td {
border: 4px solid var(--main-color);
padding: .2em .5em;
}
td:first-child {
text-align: left;
}
td:nth-child(2) {
text-align: right;
}
#debug {
text-align: left;
border: 1px solid black;
margin: 1em;
padding: 0.5em;
font-size: 70%;
}
#chart_c {
vertical-align: top;
display: inline-block;
width: 500px;
max-width: 100vw;
height: 255px;
}
@media screen and (min-width: 1046px) {
#chart_c {
margin-top: 100px;
}
}
#link {
margin: 1em;
font-size: 90%;
}
#link img {
width: 80vw;
max-width: 300px;
}
#src {
margin: .5em;
font-size: 80%;
}
a {
color: gray !important;
}
.buttons{
text-align: center;
}
</style>
</head>
<body>
<h1 id=title>COVID-19 Fukui</h1><div class=subtitle>福井県 新型コロナウイルス対策ダッシュボード</div>
<div id="main">
<div id="chart_c"><canvas id="chart"></canvas></div>
<div id="table_c"></div>
</div>
<div class="buttons">
<button type="button" onclick="update()">更新</button>
</div>
<div id="link"><a href=https://www.stopcovid19.jp/><img alt="COVID-19 JAPAN" src="covid19japan.png"/></a></div>
<div id="src">
DATA: CC BY 「<a href=https://www.pref.fukui.lg.jp/doc/kenkou/kansensyo-yobousessyu/corona.html>新型コロナウイルス感染症について | 福井県ホームページ</a>」「<a href=https://www.pref.fukui.lg.jp/doc/kenkou/kansensyo-yobousessyu/corona_d/fil/200319-1.pdf>新型コロナウイルス感染症の患者の発生について</a>」を <a href=https://app.sabae.cc/api/covid19fukui.json>JSON形式</a>に加工(<a href=https://github.com/code4sabae/app_sabae_cc/blob/master/covid19fukui.js>src on GitHub</a>)<br>
APP:CC BY <a href='https://fukuno.jig.jp/2784'>fukuno.jig.jp</a> <a href=https://github.com/code4sabae/covid19>src on GitHub</a><br>
</div>
<img id=qrcode><script>addEventListener("load", () => qrcode.src = "https://chart.apis.google.com/chart?chs=140x140&cht=qr&chl=" + encodeURIComponent(document.location))</script><br>
</div>
</body>
</html>