xxxxxxxxxx
44
let data;
function preload() {
//data = loadTable(url, 'csv', 'header');
data = loadTable('cats_vs_dogs.csv', 'csv', 'header');
}
function setup() {
createCanvas(800, 600);
noLoop();
}
function draw() {
background(25);
//this makes sure there is content in the data
if (data) {
//get the amount of rows in the CSV
let numRows = data.getRowCount();
//get the column titled state
let state = data.getColumn('state');
let n_households = data.getColumn("n_households");
print(state);
print(n_households);
//iterate over the number of rows
for (let i = 0; i < numRows; i++) {
let x = 50;
let y = 100+(i*20); //i*20 will increment by 20 each time the loop runs
let w = n_households[i];
let h = 10;
//let c = map(n_households[i],0,5,20,255);
rect(x,y,w,h);
}
}
}