This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
indextemplate.html
56 lines (49 loc) · 1.76 KB
/
indextemplate.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
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["timeline"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var xmlhttp = new XMLHttpRequest();
var url = "timeline.json";
xmlhttp.onreadystatechange = function() {
if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
var data = JSON.parse(xmlhttp.responseText);
actualDraw(data);
}
}
xmlhttp.open("GET", url, true);
xmlhttp.send();
function actualDraw(data) {
var container = document.getElementById('timeline');
var chart = new google.visualization.Timeline(container);
var dataTable = new google.visualization.DataTable();
dataTable.addColumn({ type: 'string', id: 'Source' });
dataTable.addColumn({ type: 'string', id: 'Command' });
dataTable.addColumn({ type: 'number', id: 'Start' });
dataTable.addColumn({ type: 'number', id: 'End' });
for (var i = 0; i < data.length; ++i) {
var event = data[i];
if (!event.start && event.end) {
continue;
}
var row = [];
row.push(event.source);
row.push(event.command.name_ || event.command);
row.push(event.start);
row.push(event.end);
dataTable.addRow(row);
}
var options = {
timeline: { colorByRowLabel: true }
};
chart.draw(dataTable, options);
}
}
</script>
</head>
<body>
<div id="timeline" style="width: 900px; height: 400px;"></div>
</body>
</html>