xxxxxxxxxx
73
let table;
let delay = 1000;
function preload() {
table= loadTable("womenshappiness.csv", "csv", "header");
}
setTimeout(function setup() {
angleMode(DEGREES);
createCanvas(1000, 1000);
background(0);
//console.log(table);
for(let r=0; r<table.getRowCount();r++) {
setTimeout(function setuperka() {
const name = table.getString(r, "Country");
const rank= table.getNum(r, "Rank");
const score = table.getNum(r, "Score");
const x = 2*(180-rank)*cos(rank*5)+width/2;
const y = 2*(180-rank)*sin(rank*5)+height/2;
const scoremap = map(score, 0, 100, 0, 30);
ellipse(x, y, scoremap);
fill(255); }, 1000);
}
}, 1000);
// setTimeout (setup(), 10000);
function draw() {
textAlign(LEFT, BOTTOM);
for(let r=0; r<table.getRowCount();r++) {
const name = table.getString(r, "Country");
const rank= table.getNum(r, "Rank");
const score = table.getNum(r, "Score");
const x = 2*(180-rank)*cos(rank*5)+width/2;
const y = 2*(180-rank)*sin(rank*5)+height/2;
const scoremap = map(score, 0, 100, 0, 30);
ellipse(x, y, scoremap);
fill(0);
// text(name, x+30, y);
// console.log(rank);
// console.log(name);
let xtext=2.5*(180-rank)*cos(rank*5)+width/2-19;
let ytext=2.5*(180-rank)*sin(rank*5)+height/2;
if (rank>=97 && rank<=116){
xtext = 2.5*(180-rank)*cos(rank*5)+width/2-35;
}
if (rank>=136) {
xtext = 2.5*(180-rank)*cos(rank*5)+width/2+5;
}
let d = dist(mouseX, mouseY, x, y);
if (d < scoremap/2) {
fill(255, 0, 0);
text(name, xtext, ytext);
ellipse(x, y, scoremap);
} else {
fill(0);
text(name, xtext, ytext);
fill(255);
ellipse(x, y, scoremap);
fill(255);
}
function mouseClicked() {
fill(255, 0, 0);
}
}
}