xxxxxxxxxx
33
let table;
let spacing;
function preload() {
// Load CSV file into a Table object
// "header" option indicates the file has a header row
table = loadTable("assets/multiTimeline.csv", "csv");
}
function setup() {
createCanvas(600, 600);
// spacing is rowcount - 3 since the first three rows are superfluous
spacing = width / (table.getRowCount() - 3);
}
function draw() {
background(255);
// You can access iterate over all the rows in a table
// start at row 3 since the first few rows are filler
beginShape();
for (let i = 3; i < table.getRowCount(); i++) {
let row = table.getRow(i);
// You can access the fields via their column name (or index)
// interest in topic: range 0 - 100
let interest = row.getNum(1);
let x = (i - 3) * spacing;
let y = map(interest, 0, 100, height, 10);
curveVertex(x, y);
}
endShape();
}