I am new to processing and I have been using Ben Fry's Visualizing Data to teach my self programming. This is the whole script from chapter 4;
FloatTable data;
float dataMin, dataMax;
float plotX1, plotY1;
float plotX2, plotY2;
int currentColumn = 0;
int columnCount;
int yearMin, yearMax;
int[] years;
int yearInterval = 10;
PFont plotFont;
void setup() {
size(720, 405);
data = new FloatTable("milk.tsv");
columnCount = data.getColumnCount();
years= int(data.getRowNames());
yearMin = years[0];
yearMax = years[years.length - 1];
dataMin = 0;
dataMax = data.getTableMax();
//Corners ofthe plotted time series
plotX1 = 50;
plotX2 = width - plotX1;
plotY1 = 60;
plotY2 = height - plotY1;
plotFont = createFont("Monospaced", 20);
textFont(plotFont);
smooth();
}
void draw() {
background(224);
// show the plot area as a white box.
fill(255);
rectMode(CORNERS);
noStroke();
rect(plotX1, plotY1, plotX2, plotY2);
//Draw the title of the current plot.
fill(0);
textSize(20);
String title = data.getColumnName(currentColumn);
text(title,plotX1, plotY1 - 10);
strokeWeight(5);
//Draw the data for the first column.
stroke(#5679C1);
drawDataPoints(currentColumn);
}
//Draw the data as a series of points.
void drawDataPoints(int col){
int rowCount = data.getRowCount();
for (int row= 0; row < rowCount; row++){
if (data.isValid(row, col)) {
float value = data.getFloat(row, col);
float x = map(years[row], yearMin, yearMax, plotX1, plotX2);
float y = map(value, dataMin, dataMax, plotY2, plotY1);
point(x,y);
}
}
}
void drawYearLabels(){
fill(0);
textSize(10);
textAlign(CENTER, TOP);
for (int row= 0; row<rowCount; row++) {
if (years[row] % yearInterval == 0) {
float x = map(years[row], yearMin, yearMax, plotX1, plotX2);
text(years[row], x, plotY2 + 10);
}
}
}
The error message simply read 'Cannnot find anything named "rowCount" ', I kinda understand what the problem is but I cant seem to resolve the problem. Any help would be much appreciated.