-
Notifications
You must be signed in to change notification settings - Fork 0
/
Linegraph.js
58 lines (36 loc) · 913 Bytes
/
Linegraph.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
51
52
53
54
55
56
57
let graphY = []; //graph Y axe Arraybuffer
let numPts = 20; //graph X axe resolution
function createGraph(){
graphY.push(points/2);
drawLines();
drawEllipses();
}
function drawEllipses(){
rightCanvas.noStroke();
for(let i =0; i < graphY.length; i++){
let x = i * (width / (numPts-1));
let y = graphY[i];
rightCanvas.ellipse(x/2, height+ -y, 4);
}
}
function drawLines(){
rightCanvas.stroke(0);
let px = 0;
let py = graphY[0];
for(let i =0; i < graphY.length; i++){
let x = i * (width / (numPts-1));
let y = graphY[i];
rightCanvas.line(px/2,height+ -py, x/2,height+ -y);
px = x;
py = y;
}
}
function moveGraph(){
if (tView === false){
if (graphY.length*2 > numPts){
graphY.shift()
}
}else if(tView === true){
numPts++
}
}