var table; var nCol; var nRow; var orgX; var orgY; var widthXLine; // x-axis width var lengthYLine; // y-axis length var widthXSubset; // width for a subset which is the length of x-axis and space var lengthYSubset // length for a subset which is the length of y-axis and space var yCol; var xCol = 7; // Set x-axis from dataset column 7 var nX = 3; // Numbers of graph horizontally var nY = 1; // Numbers of graph vertically var xAxisLabel = "Airport"; var list_variable = new Array(8,10,21) // The list of column want to show var list_variable_name = new Array("Numbers of Delayed Flights","Total Numbers of Flights","Numbers of On Time Flights"); function preload(){ table = loadTable('airlines.csv','csv','header'); } function setup() { var xSize = 2000; var ySize = 800; createCanvas(xSize,ySize); nCol = table.getColumnCount(); nRow = table.getRowCount(); orgX = 100; orgY = ySize - 100; widthXSubset = (xSize-200)/nX; lengthYSubset = (ySize -200)/nY; widthXLine = widthXSubset*0.8; lengthYLine = lengthYSubset*0.8; // Set line length, to be 90% of subset in order to leave space if(lengthYLine>widthXLine){ lengthYLine = widthXLine; } else if(widthXLine > lengthYLine){ widthXLine = lengthYLine; } // Here make the axis be symmetric } function draw() { background(255); for(var hor=0; horlist_variable.length){ break; } var yMax = 0; yCol = list_variable[counter]; orgX_local = orgX + xDim*widthXSubset; orgY_local = orgY + yDim*lengthYSubset; for(var i =0; i yMax){ yMax = Number(table.getString(i,yCol)); } } // Find the maximum value of x-axis and y-axis xWidth = widthXLine/xLabel.length; yLength = lengthYLine/yMax; for(var c = 0; c