This repository has been archived by the owner on May 30, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
47 lines (43 loc) · 1.49 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
<doctype html>
<head>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<h1 style="text-align: center">Wolfshunt Tracker</h1>
<div id="chart"></div>
<script type="text/javascript">
async function main() {
const data = await fetch('data.json').then((data) => data.json())
const currentProgress = new Map()
data.forEach(({ name, id, progress, timestamp }) => {
if (currentProgress.get(id) == undefined || currentProgress.get(id) < progress) {
currentProgress.set(id, progress)
}
})
const topTeams = [...currentProgress.entries()]
.sort(([id1, progress1], [id2, progress2]) => progress2 - progress1)
.map(([id, progress]) => id)
.slice(0, 15)
const tracesMap = new Map()
data.forEach(({ name, id, progress, timestamp }) => {
if (!topTeams.includes(id)) {
return
}
if (!tracesMap.has(id)) {
tracesMap.set(id, { x: [], y: [], name })
}
const trace = tracesMap.get(id)
trace.x.push(timestamp)
const maxScore = new Date(timestamp) < new Date('2019-03-09T14:00:00.000Z') ? 3012 : 3062;
trace.y.push(progress * maxScore)
});
Plotly.newPlot('chart', [...tracesMap.values()], {
yaxis: {
range: [0, 3333],
},
}, { });
}
main().catch(console.error)
</script>
</body>
</doctype>