-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBarChart.pde
More file actions
188 lines (131 loc) · 4.74 KB
/
BarChart.pde
File metadata and controls
188 lines (131 loc) · 4.74 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
void axis(){
//axis
strokeWeight(0.5f);
stroke(0xff8F9090);
line(200,450,1750,450);
line(200,0,200,800);
//axis labels
int xStart = table.getRow(1).getInt("Year");
int yStart = 25;
fill(1);
for(int a = xStart, incrementor = 0; a <= 2019; a++, incrementor +=48){
text(a, 210 + incrementor, 500);
}
for(int a = yStart; a >= -25; a-=5){
text(a, 180, 450-a*15);
}
}
void drawBars(){ //all data
background(0xffFFFFFF); //taking into consideration black background after snowfall
stroke(0xff8F9090); //cleaner bars
strokeWeight(0.25);
int counter = 0;
////max temp
//IF BAR IS ON WHILE MAX AND MIN OFF, THEN SHOW NORMAL BAR GRAPH
if(bar.isOn() && (!max.isOn() && !min.isOn())){
fill(0xffF08C8C);
for(TemperatureData d: tempData){
rect(xMin + counter, yMin - d.maxTemp*multFact, initialWidth, d.maxTemp*multFact);
counter+=4;
}
//min temp
counter = 0;
fill(0xff8CEBF0);
for(TemperatureData d: tempData){
rect(xMin + counter, yMin - d.minTemp*multFact, initialWidth, d.minTemp*multFact);
counter+=4;
}
//temporary solution to maxTemp graphs under 0 not showing: just redraw
counter = 0;
fill(0xffF08C8C);
for(TemperatureData d: tempData){
if(d.maxTemp < 0){
rect(xMin + counter, yMin - d.maxTemp*multFact, initialWidth, d.maxTemp*multFact);
}
counter+=4;
}
}
//IF BAR AND MAX IS ON, SHOW ONLY MAX
else if(bar.isOn() && max.isOn()){
fill(0xffF08C8C);
for(TemperatureData d: tempData){
rect(xMin + counter, yMin - d.maxTemp*multFact, initialWidth, d.maxTemp*multFact);
counter+=4;
}
}
//IF BAR AND MIN IS ON, SHOW ONLY MIN
else if(bar.isOn() && min.isOn()){
counter = 0;
fill(0xff8CEBF0);
for(TemperatureData d: tempData){
rect(xMin + counter, yMin - d.minTemp*multFact, initialWidth, d.minTemp*multFact);
counter+=4;
}
}
axis();
for(Button b: buttons){
if(b.isOn()){
drawBarMonth();
}
}
}
//portraying bar graphs according to month buttons pushed
void drawBarMonth(){
println("hiya!~");
background(#FFFFFF); //taking into consideration black background after snowfall
int count = 1;
int counter = 0;
for(Button a: buttons){ //check each individual button to see which one is on
if(a.isOn() && (!min.isOn() && !max.isOn())){ // when max and min are unselected
fill(0xffF08C8C);
for(int x = 0; x < tempData.length; x++){
if(tempData[x].date.Month == count){
rect(xMin + counter, yMin - tempData[x].maxTemp*multFact, initialWidth, tempData[x].maxTemp*multFact);
}
counter+=4;
}
//min temp
counter = 0;
fill(0xff8CEBF0);
for(int x = 0; x < tempData.length; x++){
if(tempData[x].date.Month == count){
rect(xMin + counter, yMin - tempData[x].minTemp*multFact, initialWidth, tempData[x].minTemp*multFact);
}
counter+=4;
}
//temporary solution to maxTemp graphs under 0 not showing: just redraw
counter = 0;
fill(0xffF08C8C);
for(int x = 0; x < tempData.length; x++){
if(tempData[x].maxTemp < 0){
if(tempData[x].date.Month == count){
rect(xMin + counter, yMin - tempData[x].maxTemp*multFact, initialWidth, tempData[x].maxTemp*multFact);
}
}
counter+=4;
}
//////////////
}
else if(a.isOn() && max.isOn()){
fill(0xffF08C8C);
for(int x = 0; x < tempData.length; x++){
if(tempData[x].date.Month == count){
rect(xMin + counter, yMin - tempData[x].maxTemp*multFact, initialWidth, tempData[x].maxTemp*multFact);
}
counter+=4;
}
}
else if(a.isOn() && min.isOn()){
counter = 0;
fill(0xff8CEBF0);
for(int x = 0; x < tempData.length; x++){
if(tempData[x].date.Month == count){
rect(xMin + counter, yMin - tempData[x].minTemp*multFact, initialWidth, tempData[x].minTemp*multFact);
}
counter+=4;
}
}
count++;
}
axis();
}