var table; function preload() { table = loadTable('classics_reduced.csv','csv', 'header'); } function draw() { clear(); createCanvas(900, 900); var titles = [] var words = []; var gf = []; var pol = []; var names = []; for (var x=0; x < table.getRowCount(); x++) { // titles append(titles, table.getString(x,28)); } for (var x=0; x < table.getRowCount(); x++) { // names append(names, table.getString(x,20)); } for (var x=0; x < table.getRowCount(); x++) { // words append(words, table.getString(x,31)); } for (var x=0; x < table.getRowCount(); x++) { // Gunning Fog append(gf, table.getString(x,15)); } for (var x=0; x < table.getRowCount(); x++) { // polarity append(pol, table.getString(x,21)); } var h = 430, w = 200; // Dim of each plot var margin = 70; var buffer = 20; line(margin, 2*margin, margin, 2*margin+h); // rank line line(margin+w, 2*margin, margin+w, 2*margin+h); // words line line(margin+2*w, 2*margin, margin+2*w, 2*margin+h); // gf line line(margin+3*w, 2*margin, margin+3*w, 2*margin+h); // polarity line textSize(14); // line headers textAlign(CENTER); textStyle(BOLD); text("Rank", margin, margin); text("Length", margin+w, margin); text("Difficulty", margin+2*w, margin); text("Polarity", margin+3*w, margin); textSize(11); // line markers textAlign(CENTER); textStyle(NORMAL); text("1", margin, 2*margin-buffer); text("100", margin, 2*margin+h+buffer); text("Longer", margin+w, 2*margin-buffer); text("Shorter", margin+w, 2*margin+h+buffer); text("Challenging", margin+2*w, 2*margin-buffer); text("Easier", margin+2*w, 2*margin+h+buffer); text("Positive", margin+3*w, 2*margin-buffer); text("Negative", margin+3*w, 2*margin+h+buffer); var len = table.getRowCount(); for (var i=0; i rankMap-1.5) && (mouseY < rankMap+1.5) && (mouseX < margin+15) && (mouseX > margin-15)) { // Hover over rank axis stroke(255,255,50); strokeWeight(3); line(margin, rankMap, margin+w, wordMap); // Draw lines line(margin+w, wordMap, margin+2*w, gfMap); line(margin+2*w, gfMap, margin+3*w, polMap); noStroke(); textAlign(LEFT); text("Title: " + titles[i], margin+3*w+10, polMap-6); text("Author: " + names[i], margin+3*w+10, polMap+6); } if ((mouseY > wordMap-1.5) && (mouseY < wordMap+1.5) && (mouseX < w+margin+15) && (mouseX > w+margin-15)) { // Hover over length axis stroke(255,255,50); strokeWeight(3); line(margin, rankMap, margin+w, wordMap); // Draw lines line(margin+w, wordMap, margin+2*w, gfMap); line(margin+2*w, gfMap, margin+3*w, polMap); noStroke(); textAlign(LEFT); text("Title: " + titles[i], margin+3*w+10, polMap-6); text("Author: " + names[i], margin+3*w+10, polMap+6); } if ((mouseY > gfMap-1.5) && (mouseY < gfMap+1.5) && (mouseX < 2*w+margin+15) && (mouseX > 2*w+margin-15)) { // Hover over difficulty axis stroke(255,255,50); strokeWeight(3); line(margin, rankMap, margin+w, wordMap); // Draw lines line(margin+w, wordMap, margin+2*w, gfMap); line(margin+2*w, gfMap, margin+3*w, polMap); noStroke(); textAlign(LEFT); text("Title: " + titles[i], margin+3*w+10, polMap-6); text("Author: " + names[i], margin+3*w+10, polMap+6); } if ((mouseY > polMap-1.5) && (mouseY < polMap+1.5) && (mouseX < 3*w+margin+15) && (mouseX > 3*w+margin-15)) { // Hover over polarity axis stroke(255,255,50); strokeWeight(3); line(margin, rankMap, margin+w, wordMap); // Draw lines line(margin+w, wordMap, margin+2*w, gfMap); line(margin+2*w, gfMap, margin+3*w, polMap); noStroke(); textAlign(LEFT); text("Title: " + titles[i], margin+3*w+10, polMap-6); text("Author: " + names[i], margin+3*w+10, polMap+6); } stroke(0); strokeWeight(0); } }