forked from scottmcn204/Group27Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBar_Chart.pde
More file actions
55 lines (51 loc) · 1.48 KB
/
Bar_Chart.pde
File metadata and controls
55 lines (51 loc) · 1.48 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
import org.gicentre.utils.stat.*;
import controlP5.*;
/**
* The ChartBar Class is used to implement the two bar charts used
* throughout the program.
* Using giCentre's BarChart
*/
class ChartBar {
BarChart barChart;
String[] airports;
ChartBar(BarChart chart, String label) {
barChart = chart;
barChart.setMinValue(0);
barChart.setMaxValue(1000);
barChart.showValueAxis(true);
barChart.showCategoryAxis(true);
barChart.setBarColour(color(0, 150, 255));
barChart.setAxisLabelColour(color(0, 45, 90));
barChart.setAxisValuesColour(color(0, 45, 90));
barChart.setCategoryAxisLabel(label);
barChart.setBarGap(6);
}
void setData(float[] data, ArrayList<String> labels, String label) {
barChart.setCategoryAxisLabel(label);
airports = new String[labels.size()];
for (int i = 0; i < labels.size(); i++) {
boolean found = false;
int count = 0;
while (!found) {
Flight temp = flights.flights.get(count);
if (temp.originCity.equals(labels.get(i))) {
airports[i] = temp.originAirport;
found = true;
}
count += 1;
}
}
barChart.setData(data);
barChart.setBarLabels(airports);
}
void transposeGraph() {
barChart.transposeAxes(true);
}
void NotTransposedGraph() {
barChart.transposeAxes(false);
}
void draw(int xpos, int ypos, int zoomer, int slider) {
barChart.draw(xpos, ypos, 600, 400);
barChart.setMaxValue(1000 + slider * zoomer);
}
}