CSV information assignment

Posted on Tuesday, October 4th, 2011 at 6:54 pm

IN PROGRESS

table: World carbon dioxide emissions data by country:
from: http://www.guardian.co.uk/news/datablog/2011/jan/31/world-carbon-dioxide-emissions-country-data-co2

first attempt:

second attempt:

CODE:

float[] numbers;
PFont label;
PFont numlabel;

void setup(){
size(800,600);
background(0);
smooth();

//load the .CSV
String[] input = loadStrings(“Total_Carbon_Dioxide.csv”);
numbers = new float[input.length - 1];
//load font
label = createFont(“HelveticaNeue-Thin.otf”, 20);
numlabel = createFont(“HelveticaNeue-Thin.otf”, 20);
String[] years = input[2].split(“,”);

//print years
for(int u=0; u < 7; u++) {
fill(255,40);
text(years[u], 90 + u *100, 20);
println(years[u]);
}
//convert the Strings into floats
for(int i=4; i < input.length; i++){
noStroke();
String[] splits = input[i].split(“,”);

//print names
fill(255,40);
textFont(label);
text(splits[0], 20, 40 + (20) * (i – 4));

// print numbers
for(int j=2; j < splits.length; j++){
numbers[j-2] = float(splits[j]);
float s = map(sqrt(numbers[j-2]),0,sqrt(10),0,5);
colorMode(HSB);
fill((i-4) * 10, 255, 255, 80);
//fill(255,50);
//textFont(numlabel);
//text(numbers[j-2], 80 + (j) *100, 40 + 20 * (i-4)); //print numbers
ellipse(80 + (j) *100,40 + 20 * (i-4),s,s);

}
}

}

void draw(){
//background(0);
drawData();

}

void drawData(){

};

Comments are closed.

Premium WordPress Themes