var table, years, majors, employed; var year_compsc = new Array(); var totalcompsc = new Array(); function preload() { table = loadTable('graduates.csv', 'csv', 'header'); } function setup() { //count the columns createCanvas(1000, 1000); majors = table.getColumn('Major'); total = table.getColumn('Total'); years = table.getColumn('Year'); employed = table.getColumn('Employed'); var j = 0 , k = 0 , l = 0 , m = 0 , n = 0; for (var i = 0; i < table.getRowCount(); i++) { if (years[i] > 1998) { if (majors[i] == "Computer Science and Math") { year_compsc[j] = years[i]; totalcompsc[j] = total[i]; //print(totalcompsc[j]); j++; } } maxlim = Math.max.apply(null, totalcompsc); maxyr = Math.max.apply(null, year_compsc); minyr = Math.min.apply(null, year_compsc); } print(table.getRowCount() + ' total rows in table'); print(table.getColumnCount() + ' total columns in table'); } function draw() { background(255); rect(100, 10, 750, 800); scattermatrix(100, 10, 375, 400, year_compsc, year_compsc, minyr, maxyr, 0); scattermatrix(850, 810, 380, 405, totalcompsc, totalcompsc, 0, 0, maxlim); line(100,400,850,400); line(450,10,450,810); line(850, 810, 380, 810); line(850, 405, 850, 810); scattermatrix2(110,405,810,375,year_compsc,totalcompsc,minyr,maxyr,maxlim); scattermatrix3(450,10,850,400,year_compsc,totalcompsc,minyr,maxyr,maxlim); // line(100,405,100,810) // line(100,810,375,810) line(450,10,850,10) line(850,10,850,400); } function scattermatrix2(linex, liney, lineydiff, linexdiff, yeard, totald, minyr, maxyr, maxlim) { var interval = maxlim/10; for(var k = 0;k posx1 && mouseY > posy1 && mouseX < posx1 + 7 && mouseY < posy1 + 7) { text(sval, mouseX + 10, mouseY - 10); } } } /*text(0,annox,annoy); maxlim =Math.max.apply(null, total); maxyr = Math.max.apply(null,year); minyr = Math.min.apply(null,year); for(var l =minyr;l posx1 && mouseY > posy1 && mouseX < posx1+3 && mouseY < posy1 + 3) { text(sval, mouseX+20, mouseY); } }*/ }