class Graph { // properties String term; int[]termArrCount; int[] data; float CurveSmoothing; float columnWidth; float maxColumnHeight; float ColumnHeightRatio; int i=0; float x; float y; float[] tempX; float[] tempY; float boxWidth; float boxHeight; color LineColour; // constructors Graph(String term){ this.term = term; } // methods void addData(int[]termArrCount){ this.termArrCount = termArrCount; } void display(int x1, int y1, int wid, int heigh, color f, int gCurve) { x = x1; y = y1; boxWidth = wid; boxHeight = heigh; data = termArrCount; LineColour = f; CurveSmoothing = gCurve; columnWidth = boxWidth / (data.length-1); columnWidth = int(columnWidth); maxColumnHeight = max(data); ColumnHeightRatio = boxHeight / maxColumnHeight; tempX = new float[data.length]; tempY = new float[data.length]; update(); } void update(){ beginShape(); vertex(x,y+boxHeight+7); vertex(x,y+boxHeight); fill(LineColour); stroke(LineColour); for(int j=0; j < data.length; j++) { tempX[j] = x + j*columnWidth; tempY[j] = y + boxHeight - data[j]*ColumnHeightRatio; } //animate the drawing of the graph //iterate over the size of i until we reach the size of the data if(i < data.length) { //incrementally increase the number of curvevertices each time around for(int k=0; k < i; k++) { curveVertex(tempX[k], tempY[k]); } i++; } else { for(int k=0; k < data.length; k++) { curveVertex(tempX[k], tempY[k]); } } // vertex(tempX[data.length-1],tempY[data.length-1]); vertex(x+boxWidth, y+boxHeight); vertex(x+boxWidth, y+boxHeight+7); endShape(); /* // This adds numbers next to the points stroke(255, 60); fill(color(r,g,b,a)); int heightAboveGraph = 12; for (int l = 0; l < i; l++) { if ((l > 0) && (l