let table; let width; let height; let margin; let intervals; let y_max; let x_max; let bar_width; let interval_width_px; let tick_width; let text_size; let data_points = []; let total_violent_vals = []; let pop_vals = []; let matrix_size ; let matrix_cell_width ; let matrix_cell_height ; let attributes = []; let states_vals_map_x ; let states_vals_map_y ; let no_of_Records ; let states = []; let text_width_box_trellis; let states_total_vals_x_max; let states_total_vals_x_min; let states_total_vals_y_max; let states_total_vals_y_min; function preload() { table = loadTable('county_crime.csv','csv','header') } function setup() { width = 800; height = 800; margin = 100; intervals = 10; bar_width = 20; interval_width_px = (height - 2*margin)/10; tick_width = 3; text_size = 5; matrix_size = 3; matrix_cell_width = (width - 2*margin)/matrix_size; matrix_cell_height = (height - 2*margin)/matrix_size; text_width_box_trellis = 20; //original table has 117965 records; it is taking lot of //time to create scatter plot;created a variable to try with //smaller sizes no_of_Records = 1000; states_vals_map_x = new Map(); states_vals_map_y = new Map(); //can try different states if needed //note - change matrix size if adding extra states and make sure that //its a square matrix states.push('California'); states.push('Florida'); states.push('New York'); states.push('Texas'); states.push('Illinois'); states.push('Michigan'); states.push('Virginia'); states.push('Minnesota'); states.push('North Carolina'); attributes.push('Totals.Violent.All'); attributes.push('Totals.Property.All'); createCanvas(width,height); background(245,255,250); //setting plot area setPlotArea(); //draw matrix cells drawMatrixCells(); //load data points with values from .csv loadDataPointsForScatterPlot(attributes); //plot y-axis ticks plotYTicks(); //plot x-axis ticks plotXTicks(); } function drawMatrixCells() { push(); translate(margin,margin); for(var i=0;i