This repository has been archived by the owner on Jul 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
72 lines (62 loc) · 2.25 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
69
70
71
72
<!DOCTYPE html>
<html lang="ja">
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['corechart', 'line']});
google.charts.setOnLoadCallback(drawChart);
const voteData = new Array();
const url = 'https://owatan.github.io/favo-15th-vote-ranking/favo.txt';
function graphData() {
fetch(url)
.then(function (response) {
return response.text();
})
.then(function(text) {
// voteData is favo.txt
for (const e of text.split('\n')) {
if (e.split('\t').length != 1) {
// time を取り除くための slice()
voteData.push(e.split('\t').slice(1));
}
};
});
}
graphData();
function drawChart(){
var data = new google.visualization.DataTable();
// 日付表記での時間を追加
data.addColumn('datetime', 'Date');
// 時間軸はさっき追加したのでキャラ名のみ追加
for (const e of voteData[0].slice(1)) {
data.addColumn('number', e);
}
// header を取り除くための slice()
for (const p of voteData.slice(1)) {
// 先頭は時間なので concat() で無理やりくっつける
// 数値は文字列なので型変換
data.addRow([new Date(p[0] * 1000)].concat(p.slice(1).map( str => parseInt(str, 10) )));
}
var options = {
chart: {
title: '15周年 FAVORITE ヒロイン総選挙 投票数推移',
subtitle: '取得期間: 2019/03/09 10:00 - 2019/04/09 18:00'
},
width: 1000,
height: 1000
};
var chart = new google.charts.Line(document.getElementById('chart'));
chart.draw(data, google.charts.Line.convertOptions(options));
}
</script>
</head>
<body>
<div id="chart"></div>
<a href="http://www.favo.co.jp/cgi/15th_vote/15th_vote.cgi">
http://www.favo.co.jp/cgi/15th_vote/15th_vote.cgi
</a> /
<a href="https://github.com/owatan/favo-15th-vote-ranking">
Github (owatan/favo-15th-vote-ranking)
</a>
</body>
</html>