Table donationTable; Table gridTable; int rowCount; int gridCount; float dataMin = MAX_FLOAT; float dataMax = MIN_FLOAT; float amountMin = MAX_FLOAT; float amountMax = MIN_FLOAT; float closestDist; String closestText; String closestTotal; float closestTextX; float closestTextY; float closestTotalY; String Label; color donorColor; float donationTotal; float donationLevel5 = 0; float donationLevel10 = 0; float donationLevel25 = 0; float donationLevel50 = 0; float donationLevel100 = 0; float donationLevel500 = 0; void setup() { size(1000,400); colorMode(HSB,100); PFont font = loadFont("LucidaSans-10.vlw"); textFont(font); // load table of donations over time donationTable = new Table("donations.tsv"); rowCount = donationTable.getRowCount(); for (int row=0;row dataMax){ dataMax = value; } if (value < dataMin){ dataMin = value; } } // load table for time grid gridTable = new Table("dateGrid.tsv"); gridCount = gridTable.getRowCount(); for (int row=0;row amountMax){ amountMax = value; } if (value < amountMin){ amountMin = value; } } } void draw() { smooth(); background(0); closestDist = MAX_FLOAT; fill(100,75); textAlign(LEFT); text("June 2009 IxDA Infrastructure Fundraiser: donations over time", 20, 30); // get donations from table & calculate total float donationTotal = 0; for(int row = 0; row < rowCount; row++) { float donationTime = donationTable.getFloat(row,0); //get time of donation float donationAmount = donationTable.getFloat(row,1); //get amount of donation donationTotal += donationAmount; drawData(row,donationTime,donationAmount,donationTotal); } // add rollover labels for amounts if (closestDist != MAX_FLOAT) { fill(100); textAlign(CENTER); text(closestText, closestTextX, closestTextY); fill(60,50,100,75); text(closestTotal, closestTextX, closestTotalY); } // draw time grid for(int row = 0; row < gridCount; row++) { float x = gridTable.getFloat(row,0); //get time for grid float gridX = map(x,dataMin, dataMax, 40, width-40); int gridLabel = gridTable.getInt(row,1); //get label int gridDate = gridTable.getInt(row,2); // get date String label = str(gridLabel); if(gridLabel == 0){ // if its the start of a day, then label with date stroke(50,50,100,30); fill(50,0,100,50); label = "Jun " + gridDate ; }else{ stroke(50,50,100,10); fill(50,50,100,20); } noSmooth(); line(gridX,40,gridX,height-30); textAlign(CENTER); text(label, gridX, height-10); } // draw the amounts fill(50,0,100,50); textAlign(RIGHT); text(round(donationLevel5), 30, map(-7, amountMin, amountMax, height - 40,60)); text(round(donationLevel10), 30, map(7, amountMin, amountMax, height - 40,60)); text(round(donationLevel25), 30, map(25, amountMin, amountMax, height - 40,60)); text(round(donationLevel50), 30, map(45, amountMin, amountMax, height - 40,60)); text(round(donationLevel100), 30, map(95, amountMin, amountMax, height - 40,60)); text(round(donationLevel500), 30, map(amountMax-20, amountMin, amountMax, height - 40,60)); } //void mapHeight(float amount){ // float x = map(amount, amountMin, amountMax, height - 40,60); // return x; //} void drawData(int row, float donationTime, float donationAmount, float donationTotal) { float x = map(donationTime, dataMin, dataMax, 40, width-40); float y = map(donationAmount, amountMin, amountMax, height - 40,60); float totaly = map(donationTotal, 0, 15000, height - 40,60); // default settings color donorColor = color(0,100,100,33); color totalColor = color(60,100,100,75); float radius = 2.5; float radius2 = 0.5; // set up color coding for amounts color donor5 = color(0,255,255,33); color donor10 = color(10,100,100,33); color donor25 = color(20,100,100,33); color donor50 = color(30,100,100,33); color donor100 = color(40,100,100,33); color donor500 = color(50,100,100,33); if (donationAmount <= 5) { donorColor = donor5; }else if(donationAmount <=10){ donorColor = donor10; }else if(donationAmount <= 25){ donorColor = donor25; }else if(donationAmount <= 50){ donorColor = donor50; }else if(donationAmount <= 100){ donorColor = donor100; }else{ donorColor = donor500; } // rollover section float d = dist(x,y,mouseX,mouseY); float b = dist(x,totaly,mouseX,mouseY); if(b