-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
99 lines (91 loc) · 3.6 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
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
<!doctype html>
<html lang="en">
<head>
<title>SwiftWasm Tracker</title>
<meta content="text/html;charset=utf-8" http-equiv="Content-Type" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css"
integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://code.highcharts.com/highcharts.js"></script>
<script>
function humanReadableFileSize(bytes) {
const units = ["B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"];
let unitIndex = 0;
while (Math.round(bytes) >= 1024 && unitIndex < units.length) {
bytes /= 1024;
++unitIndex;
}
return (Math.round(bytes * 100) / 100) + " " + units[unitIndex];
}
async function start() {
const response = await fetch("./data.json");
const json = await response.json();
const series = [
{
name: "ubuntu20.04_x86_64",
data: json.artifacts.map(artifact => {
return { y: artifact.size_in_bytes, x: Date.parse(artifact.created_at), artifact }
})
},
]
Highcharts.chart("chart", {
chart: {
zoomType: "x"
},
title: {
text: "hello.wasm"
},
xAxis: {
type: 'datetime',
title: {
text: 'Date',
},
max: Date.parse(json.artifacts[0].created_at),
min: Date.parse(json.artifacts[json.artifacts.length - 1].created_at),
},
yAxis: {
title: {
text: "File Size"
},
labels: {
formatter: function () {
return humanReadableFileSize(this.value);
}
}
},
tooltip: {
formatter: function () {
let tooltip = ""
for (const key in this.point.artifact) {
let value = this.point.artifact[key];
if (key == "commit") {
const commitLink = "https://github.com/swiftwasm/swift/commit/" + this.point.artifact.commit
value = "<a href='" + commitLink + "' target='_blank'>" + value + "</a>"
} else if (key == "run_id") {
const runLink = "https://github.io/swiftwasm/swift/runs/" + value
value = "<a href='" + runLink + "' target='_blank'>" + value + "</a>"
}
tooltip += `<b>${key}</b>: ${value}<br>`
}
return tooltip;
},
style: {
pointerEvents: "auto",
}
},
series
});
}
document.addEventListener("DOMContentLoaded", start);
</script>
</head>
<body>
<div class="container">
<h1><a href="https://github.com/swiftwasm" target="_blank">SwiftWasm</a> size tracker</h1>
<div id="chart">
<div id="loading">
Loading data...
</div>
</div>
</div>
</body>
</html>