-
Notifications
You must be signed in to change notification settings - Fork 24
/
mhlw-beds.html
170 lines (160 loc) · 5.05 KB
/
mhlw-beds.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
<!DOCTYPE html><html lang="ja"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title>新型コロナウイルス感染症患者の療養状況 病床使用率 - 厚労省発表データ</title>
<meta property="og:title" content="新型コロナウイルス感染症患者の療養状況 病床使用率 - 厚労省発表データ">
<link rel="apple-touch-icon" href="mhlw-beds.png">
<meta name="twitter:card" content="summary_large_image">
<meta property="og:image" content="https://www.stopcovid19.jp/mhlw-ogp/20210911223026.png">
<meta name="twitter:image" content="https://www.stopcovid19.jp/mhlw-ogp/20210911223026.png">
<meta name="format-detection" content="telephone=no"/>
<script type='module'>
import util from 'https://taisukef.github.io/util/util.mjs'
import tabularmaps from './tabularmapsjapan.mjs'
window.onload = async () => {
//const url = "https://www.stopcovid19.jp/data/covid19japan_beds/latest.csv";
const url = "./data/covid19japan_beds/latest.csv";
const data = await util.fetchCSVtoJSON(url);
console.log(data);
lastUpdate.textContent = "更新日: " + data[0].更新日;
const shownames = ["入院患者病床使用率", "重症患者病床使用率", "宿泊療養施設居室使用率"];
shownames.forEach((n) => {
const opt = document.createElement("option");
opt.value = n;
opt.textContent = n;
sel.appendChild(opt);
});
const showunit = "%";
const show = () => {
const showname = sel.value;
const getKPI = (pname, cname) => {
const p = data.find(a => a.都道府県名 === cname);
const kpi = p[showname];
const unit = showunit;
if (kpi.endsWith(unit)) {
return [kpi.substring(0, kpi.length - unit.length), unit];
}
return [kpi, unit];
};
const colorTabularMaps = (pname, tmap) => {
let min = 0;
let max = 100;
/*
for (const c of tmap.children) {
const cname = c.cellname;
if (cname !== "-") {
const [kpi, _] = getKPI(pname, cname);
if (isNaN(kpi)) continue;
if (kpi < min) { min = kpi; }
if (kpi > max) { max = kpi; }
}
}
*/
for (const c of tmap.children) {
const cname = c.cellname;
if (cname !== "-") {
const [kpi, _] = getKPI(pname, cname);
if (isNaN(kpi)) continue;
const n = (parseFloat(kpi) - min) / (max - min);
const h = 0;
const s = 80;
const l = 100 - n * 50;
const col = `hsl(${h},${s}%,${l}%)`;
//const col = `rgba(200,50,50,${l / 100 * .5})`;
c.style.backgroundColor = col;
c.style.color = "black";
//c.appendChild(val);
//console.log(kpi, l, col);
}
}
};
const setCellContent = (c, pname, cname) => {
c.textContent = "";
const cr = tag => document.createElement(tag);
const div = cr("div");
div.className = "name";
div.textContent = cname;
c.appendChild(div);
const div2 = cr("div");
div2.className = "val";
const [kpi, unit] = getKPI(pname, cname);
div2.textContent = (isNaN(kpi) ? "-" : kpi) + unit;
c.appendChild(div2);
c.onclick = () => {
const url = "https://www.stopcovid19.jp/beds_graph.html#" + cname;
window.open(url, "_blank");
};
};
tabularmaps.showJapan(setCellContent, colorTabularMaps, true);
}
const nsel = document.location.hash.substring(1) || 0;
sel.selectedIndex = nsel;
show();
sel.onchange = () => {
const nsel = sel.selectedIndex;
if (nsel) {
document.location.hash = "#" + nsel;
} else {
history.replaceState(null, null, " ");
}
show();
};
};
</script>
<style>
body {
font-family: sans-serif;
text-align: center;
}
h1 {
font-size: 2.8vw;
margin: 1vw 0 0vw 0;
padding: 0;
}
/* tabularmaps */
#tmapc {
max-width: 700px;
margin: 0 auto;
}
#tmapc span {
font-size: min(2.0vmax, 20px);
align-items: center;
justify-content: center;
border-radius: .5vmax;
border: .1vmax solid #333;
padding: .2vmax .2vmax;
margin: .2vmax;
}
/* other */
#sel {
font-size: 130%;
margin: .3em;
}
#banner {
width: 80vw;
margin: 1vw;
}
/* credit */
.credit {
margin: 20px;
text-align: center;
font-size: 80%;
}
a {
color: #666 !important;
}
</style>
</head>
<body>
<h1>新型コロナウイルス感染症患者の療養状況 病床使用率</h1>
<select id="sel"></select>
<div id="tmapc"></div>
<div id=lastUpdate></div>
<a href="https://www.stopcovid19.jp/"><img id="banner" src="img/stopcovid19_banner.png"><br>
毎日更新「COVID-19 新型コロナウイルス対策ダッシュボード」もどうぞ</a>
<div class="credit">
APP: CC BY <a href=https://fukuno.jig.jp/2923>@taisukef 福野泰介</a><br>
DATA: <a href="https://www.mhlw.go.jp/stf/seisakunitsuite/newpage_00023.html">新型コロナウイルス感染症患者の療養状況、病床数等に関する調査結果</a> → (CSV化 by <a href="https://www.stopcovid19.jp/">COVID-19 新型コロナウイルス対策ダッシュボード</a>)<br>
LAYOUT: <a href=tabularmaps_japan.csv>TabularMaps Japan - 日本カラム地図 CSV</a> CC0 <a href=https://github.com/tabularmaps/hq>カラム地図 / TabularMaps on Github</a><br>
LIB: <a href=util.mjs>util.mjs</a> CC BY <a href=https://fukuno.jig.jp/2819>@taisukef</a><br>
</div>
</body>
</html>