-
Notifications
You must be signed in to change notification settings - Fork 0
/
company_terminated.html
201 lines (185 loc) · 4.83 KB
/
company_terminated.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
197
198
199
200
201
<!DOCTYPE html><html lang="ja"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width">
<title>廃業ダッシュボード</title>
<meta property="og:title" content="廃業ダッシュボード">
<meta name="format-detection" content="telephone=no"/>
<script type='module'>
import { CSV } from "https://js.sabae.cc/CSV.js";
import { encodeHTML } from "https://js.sabae.cc/encodeHTML.js";
import tabularmaps from 'https://www.stopcovid19.jp/tabularmapsjapan.mjs';
const type = "terminated";
window.onload = async () => {
const dates = CSV.toJSON(await CSV.fetch("./data/diff.csv"));
dates.reverse();
let first = true;
dates.forEach((d) => {
const opt = document.createElement("option");
opt.textContent = d.date;
if (first) {
opt.selected = true;
first = false;
}
sel.appendChild(opt);
});
const show = async () => {
const date = sel.value.replace(/\-/g, "");
console.log(date)
const url = "./data/diff_" + date + "_" + type + ".csv";
const data = CSV.toJSON(await CSV.fetch(url));
//console.log(data);
//lastUpdate.textContent = "更新日: " + data[0].updateDate;
const prefs = {};
for (const d of data) {
let p = prefs[d.prefectureName];
if (p) {
p.push(d);
} else {
p = prefs[d.prefectureName] = [d];
}
}
const showunit = "社";
//const showname = sel.value;
const getKPI = (pname, cname) => {
const p = prefs[cname];
const kpi = p ? p.length : 0;
const unit = showunit;
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 = 220;
const s = 50;
const l = 100 - n * 40;
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 = () => {
detail.innerHTML = (prefs[cname] || []).map(d => encodeHTML(d.name)).map(name => `<a href="https://www.google.com/search?q=${name}">${name}</a>`).join(", ");
//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.value = nsel;
*/
sel.onchange = () => {
const nsel = sel.value;
/*
if (nsel) {
document.location.hash = "#" + nsel;
} else {
history.replaceState(null, null, " ");
}
*/
show();
};
await show();
};
</script>
<style>
body {
font-family: sans-serif;
text-align: center;
margin: 0;
padding: 0;
}
h1 {
margin: 0 0 .5em;
font-size: 4vw;
padding: 2vw 0;
background-color: #718ab2;
color: white;
}
/* tabularmaps */
#tmapc {
max-width: 700px;
margin: 0 auto;
}
#tmapc span {
font-size: min(1.5vmax, 15px);
align-items: center;
justify-content: center;
border-radius: .5vmax;
border: .1vmax solid #333;
padding: .2vmax .2vmax;
margin: .2vmax;
}
/* other */
select {
font-size: 20px;
margin: 0 0 .5em 0;
}
#detail {
text-align: left;
padding: .3em;
font-size: 90%;
overflow: scroll;
display: inline-block;
border: 1px solid gray;
width: 90vw;
max-width: 700px;
height: 10em;
}
/* 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>
<br>
<!--<div id=lastUpdate></div>-->
<div id="detail"></div>
<div class="credit">
APP: CC BY <a href=https://fukuno.jig.jp/3335>@taisukef 福野泰介</a><br>
DATA: <a href="https://www.houjin-bangou.nta.go.jp/">国税庁法人番号公表サイト</a> → (CSV化ツール by <a href="https://github.com/code4fukui/gBizINFO/">gBizINFO</a>)<br>
LAYOUT: <a href=https://www.stopcovid19.jp/tabularmapsjapan.csv>TabularMaps Japan - 日本カラム地図 CSV</a> CC0 <a href=https://github.com/tabularmaps/hq>カラム地図 / TabularMaps on Github</a><br>
</div>
</body>
</html>