xxxxxxxxxx
// Carregando um CSV
//mais em https://p5js.org/reference/#/p5.TableRow/getString
let table;
let anima = 5 ;//quantos frames tem a animação
let areaM ;
let raioM ;
let button;
let myFont;//fonte do google fonts
let buttonv;
function preload() {
//my table is comma separated value "csv"
//and has a header specifying the columns labels
table = loadTable('https://deckard.openprocessing.org/user3417/visual1603117/h10f780e448780b603afd4b5119bd76b5/investimentoop2.csv',
'csv');
table2 = loadTable('https://deckard.openprocessing.org/user3417/visual1603117/h10f780e448780b603afd4b5119bd76b5/investimentoop.csv',
'csv');
//the file can be remote
//table = loadTable("http://p5js.org/reference/assets/mammals.csv",
// "csv", "header");
}
function setup() {
//count the columns
createCanvas(windowWidth,windowHeight);
areaM = [];
raioM = [];
print(table.getRowCount() + ' total rows in table');
print(table.getColumnCount() + ' total columns in table');
//print(table.getColumn('2022'));
//retorna uma lista com o nome da Coluna quando adiciona o header
//cycle through the table
for (let r = 0; r < table.getRowCount(); r++)
for (let c = 0; c < table.getColumnCount(); c++) {
if(r==1) print(table.getString(r, c));//print somente ministerio da economia
}
print(table.getString(1, 0));//retorna o valor que está na coluna 1,0 no caso uma String Ministério da Economia
print(table.getNum(1, 5));
print(table.getString(2, 0));//retorna o valor que está na coluna 2,0 no caso uma String Ministério do Trabalho
print(table.getNum(2, 5));
button=[];
let pxbt=width*0.1;
for (let ba = 1;ba<6;ba++){
button [ba]= createButton(table.getString(0,6-ba));
button[ba].size(100,40);
button[ba].position(pxbt,height*0.1);
if (ba%4==0){
button[ba].mousePressed(moveButton);
}
buttonv = table.getString(0,6-ba);
//pxbt=pxbt+150;
print(table.getString(0,6-ba))
pxbt=pxbt+150;
print(table.getString(0,6-ba))
}
}
function moveButton(){
print("2021");
}
function draw(){
background(0);
//area da elipse PI*(r*r); ou area=PI*(pow(raio,2));
let dataAreaMax = PI*(pow(width/7,2));
//print(dataAreaMax);
let ajusteTela = width*1;//para escalar todas as ellipses multiplicar por 2 ou 3
let px = width*0.095;
for (let a=1;a<=7;a++){
//calcula a area
areaM[a] = map(table.getNum(a, anima),0,3000000000,0,dataAreaMax)/ajusteTela;
//calcula o raio
raioM[a]=sqrt(areaM[a]/PI);
//desenha na tela
ellipse(px,height/2,raioM[a]*2,raioM[a]*2);
fill(255);
push();
translate(-100,100)
textFont("Signika Negative");//para fonte precisa entrar o link da fonte no arquivo html
textSize(width/80);
text(table.getString(a,0),px,height*0.7);
textSize(width/100);
text(table2.getString(a,anima),px,height*0.8);
px=px+width*0.95/7;
// print(areaM[a]+" "+raioM[a]);
pop();
}
textFont("Signika Negative");
textSize(width/10);
text(table.getString(0,anima),width/3,height*0.3);
if (frameCount % 45 == 0) anima=anima-1;
if (anima<1)anima=5;
//anima= sin(PI+millis()*0.00024);
//anima=6-floor(map(anima,-1,1,1,5));
//if(anima<1) anima=5;
anima=constrain(anima,1,5);
//text(anima,100,100);
}