forked from webmedia-lab/accelerator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
graph.html
81 lines (71 loc) · 1.76 KB
/
graph.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Accelerator</title>
<script src="./js/jquery-2.1.4.min.js" charset="utf-8"></script>
<script src="./js/jquery.canvasjs.min.js" charset="utf-8"></script>
<script src="./js/canvasjs.min.js" charset="utf-8"></script>
</head>
<body>
<div id="chart"></div>
<script>
var frames = 0;
var X = [];
var Y = [];
var Z = [];
var chart = new CanvasJS.Chart("chart", {
zoomEnabled: true,
legend: {
verticalAlign: "top",
horizontalAlign: "center",
fontSize: 14,
fontWeight: "bold",
fontFamily: "calibri",
fontColor: "dimGrey"
},
data: [{
type: "line",
showInLegend: true,
name: "X",
dataPoints: X
},
{
type: "line",
showInLegend: true,
name: "Y" ,
dataPoints: Y
},
{
type: "line",
showInLegend: true,
name: "Z" ,
dataPoints: Z
}]
});
var ws = new WebSocket('ws://localhost:9090');
ws.onmessage = function(msg){
m = JSON.parse(msg.data);
frames++
X.push({
x: frames,
y: m.x
});
Y.push({
x: frames,
y: m.y
});
Z.push({
x: frames,
y: m.z
});
if (X.length > 600) {
X.shift();
Z.shift();
Y.shift();
}
chart.render();
}
</script>
</body>
</html>