xxxxxxxxxx
71
// IIM Michael Shiloh
// October 4, 2022 Assignment 4 Data Visualization
// Abigail Mata-Hernandez
// Description: This code attempts to create a data visualization about annual global temperature means in celcius from 1880 to the present
// I chose this data set randomly from datahub.io
// Inspiration: Class, The Coding Train,
let table;
let numRows, numCols;
let date = []; mean = [];
let diagramX, diagramY;
function preload() {
table = loadTable("annual_csv.csv", "csv", "header");
}
function setup() {
createCanvas(400, 400);
background(220);
// print(table); // check if loads table
numRows = table.getRowCount();
numCols = table.getColumnCount();
//print("rows:" + numRows + "cols;"+ numCols)
// load data
for (let r = 0; r<table.getRowCount(); r++) {
date[r] = table.getString(r, 0);
mean[r] = table.getNum(r, 1);
// print(date[r] + " " + mean[r])
}
// const name = table.getString(r, "Source");
// const year = table.getNum(r, "Year");
// const x = random(0, width);
// const y = random(0, height);
// circle(x, y, year);
// text(name, x, y);
// console.log(name);
minMax();
}
function draw() {
background(240);
}
let dataMin, dataMax= 0;
function minMax() {
for(let i=0; i<numRows; i++){
if(table.getNum(i,1)>dataMax){
dataMax = table.getNum(i,1);
}
}
dataMin = dataMax;
for(let i=0; i<numRows; i++){
if(table.getNum(i,1)<dataMin){
dataMin = table.getNum(i,1);
}
}
print("max value " + dataMax + "min value " + dataMin)
}