-
Notifications
You must be signed in to change notification settings - Fork 3
/
example.js
50 lines (44 loc) · 1.15 KB
/
example.js
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
/*global $, HistoryBuffer*/
/*jshint browser: true*/
$(function () {
'use strict';
var plot;
var buffer = new HistoryBuffer(100 * 1024, 4);
var globalIndex = 0;
var chartStep = 0.0001;
var arr = [];
function updateData() {
var sin, cos, sin1, tan;
for (var i = 0; i < 2048; i++) {
sin = Math.sin(globalIndex * chartStep);
sin1 = 1 - sin;
cos = Math.cos(globalIndex * chartStep);
tan = Math.tan(globalIndex * chartStep) / 10.0;
tan = Math.min(tan, 3);
tan = Math.max(tan, -3);
globalIndex++;
arr[0] = sin, arr[1] = cos, arr[2] = sin1, arr[3] = tan;
buffer.push(arr);
}
}
plot = $.plot('#placeholder', [[], [], [], []], {
series: {
historyBuffer: buffer,
lines: {
show: true,
//lineWidth: 1
},
shadowSize: 0
},
legend: {
show: false
},
xaxis: {
show: true
},
yaxis: {
show: true
}
});
setInterval(updateData, 1);
});