xxxxxxxxxx
122
let table;
let numr;
let numc;
let date=[];
let gmsl=[];
let sze=[];
let diaX,diaY;
let dataMin,dataMax=0;
function preload()
{
table = loadTable("assests/sea.csv","csv","header");
}
function setup() {
createCanvas(windowWidth, windowHeight);
numr=table.getRowCount();
numc=table.getColumnCount();
// print(numr,numc);
for(let r=0;r<table.getRowCount();r++)
{
date[r] = table.getString(r,0);
gmsl[r] = table.getNum(r,1);
// print(date[r] + " " + gmsl[r]);
minMax();
}
}
function draw()
{clear();
background(250);
info();
diaX= width/2;
diaY= height/2;
let radius = width/8;
let angle = 360/numr;
for (let i=0;i<numr;i++)
{
sze[i]= map(gmsl[i],-3.5,79.5,0,205);
let pointx = (sze[i]+radius)*cos(radians(angle*i))+diaX;
let pointy = (sze[i]+radius)*sin(radians(angle*i))+diaY;
let cirx =radius*cos(radians(angle*i))+diaX;
let ciry =radius*sin(radians(angle*i))+diaY;
//line(cirx,ciry,pointx,pointy);
// radial line
if (i%12==0)
{ stroke('black');
strokeWeight(0.5);
}
else {
stroke('black');
strokeWeight(0.1);
}
line(cirx,ciry,pointx,pointy);
//hower-
let datasize;
let dis= dist(mouseX,mouseY,pointx,pointy);
if (dis<3)
{fill ('red)')
datasize =10;
noStroke();
circle(pointx,pointy,datasize);
textAlign(CENTER);
textSize(20);
fill('black');
text(date[i],diaX,diaY);
text(gmsl[i],diaX,diaY+20);
}
else
{ fill ('rgb(0,0,0)')
datasize =3;
noStroke();
circle(pointx,pointy,datasize);
}
// // caps
// noStroke();
// fill('black');
// circle(pointx,pointy,2)
}
}
function info()
{
textSize(15);
textAlign(CENTER);
fill('#000000');
text("This data contains “cumulative changes in sea level for the world’s oceans since 1880, based on a combination of long-term tide gauge measurements and recent satellite measurements. It shows average absolute sea level change, which refers to the height of the ocean surface, regardless of whether nearby land is rising or falling. Satellite data are based solely on measured sea level, while the long-term tide gauge data include a small correction factor because the size and shape of the oceans are changing slowly over time. (On average, the ocean floor has been gradually sinking since the last Ice Age peak, 20,000 years ago.)”",windowWidth/8,height-100,width/1.3);
}
function minMax()
{
for (let i=0;i<numr;i++)
{
if(table.getNum(i,1)>dataMax)
{
dataMax=table.getNum(i,1);
}
}
dataMin=dataMax;
for (let i=0;i<numr;i++)
{
if(table.getNum(i,1)<dataMin)
{
dataMin=table.getNum(i,1);
}
}
//print(dataMin + " " + dataMax);
}