-
Notifications
You must be signed in to change notification settings - Fork 0
/
Charts.pde
41 lines (41 loc) · 933 Bytes
/
Charts.pde
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
class Chart {
PVector pos;
PVector size;
color c;
float max =-Float.MAX_VALUE;
float min =Float.MAX_VALUE;
int lastDays = 0;
ArrayList<Float> values = new ArrayList();
public Chart(float x, float y, float w, float h, color c) {
this.pos = new PVector(x, y);
this.size =new PVector(w, h);
this.c= c;
}
public void update(float data) {
if ((int)(days*100)!=lastDays) {
values.add(new Float(data));
if (data > max) {
max =data;
}
if (data < min) {
min =data;
}
lastDays = (int)(days*100);
}
}
public void draw() {
stroke(c);
noFill();
beginShape();
strokeWeight(1.5);
float xQ = 0;
for (float v : values) {
float y = map(v, 0, (people.size()-1)*0.25, pos.y, pos.y-size.y);
float x= map(xQ, 0, 80*100, pos.x, pos.x+size.x);
vertex(x, y);
xQ++;
}
endShape();
strokeWeight(1);
}
}