xxxxxxxxxx
91
let dataLoadedFromFile;
function preload() {
incineratedLoadedFromFile = loadTable("Incinerated.csv", "csv", "header");
landwasteLoadedFromFile = loadTable("Landwaste.csv", "csv", "header");
recycledLoadedFromFile = loadTable("Recycled.csv", "csv", "header");
}
function setup() {
createCanvas(windowWidth, windowHeight);
incinerated = incineratedLoadedFromFile.getRows();
landwaste = landwasteLoadedFromFile.getRows();
recycled = recycledLoadedFromFile.getRows();
//for(let i=0;i<incinerated.length;i++) {
//console.log(incinerated[i].getString(0), incinerated[i].getNum(1));
//}
}
function draw() {
background(200);
//incinerated
let lineWidth = 20;
let centerX = (width/2)-(incinerated.length/2)*lineWidth;
let centerY = height/2;
push();
translate(centerX, centerY);
stroke(255,0,0);
noFill();
strokeWeight(5);
beginShape();
for(let i=0;i<incinerated.length;i++) {
let val = incinerated[i].getNum(1) * 2;
vertex(i * lineWidth, -val);
}
endShape();
pop();
//landwaste
push();
translate(centerX, centerY);
stroke(255, 123, 0);
noFill();
strokeWeight(5);
beginShape();
for(let i=0;i<landwaste.length;i++) {
let val = landwaste[i].getNum(1) * 2;
vertex(i * lineWidth, -val);
}
endShape();
pop();
//recycled
push();
translate(centerX, centerY);
stroke(4, 231, 98);
noFill();
strokeWeight(5);
beginShape();
for(let i=0;i<recycled.length;i++) {
let val = recycled[i].getNum(1) * 2;
vertex(i * lineWidth, -val);
}
endShape();
fill(120);
pop();
}