This repository has been archived by the owner on Mar 30, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.html
68 lines (58 loc) · 1.79 KB
/
index.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
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>dimibob-potatoes result page</title>
<style>html, body { margin: 0; padding: 0; height: 100%; overflow: hidden; }</style>
</head>
<body>
<div id="chart"></div>
<script src="node_modules/apexcharts/dist/apexcharts.min.js"></script>
<script>
const pattern = /^\[(\d+)\] (.*)$/gm
const el = document.querySelector("#chart")
function parse (text) {
let m = null
let others = 0
console.log(text)
const options = {
chart: { type: 'donut', height: '100%' },
responsive: { breakpoint: 600 },
theme: {
monochrome: {
enabled: true,
color: '#fed076',
shadeTo: 'dark',
shadeIntensity: 0.7
}
},
plotOptions: { pie: { donut: { labels: {
show: true,
total: { show: true, label: '합계' }
} } } },
series: [],
labels: [],
}
while ((m = pattern.exec(text)) !== null) {
const name = m[2]
const quantity = parseInt(m[1], 10)
if (quantity <= 3) {
others += quantity
continue
}
options.labels.push(name)
options.series.push(quantity)
}
options.labels.push('기타')
options.series.push(others)
return options
}
fetch('result.txt')
.then(res => res.text())
.then(text => new ApexCharts(el, parse(text)).render())
.catch(err => document.write(err.message) || console.error(err))
</script>
</body>
</html>