xxxxxxxxxx
44
let data;
let priceMin;
let priceMax;
let pointsMin;
let pointsMax;
function preload() {
data = loadTable("./Winemag_100.csv", "csv", "header");
}
function setup() {
createCanvas(windowWidth, windowHeight);
priceMin = data.getNum(0, "price");
priceMax = data.getNum(0, "price");
pointsMin = data.getNum(0, "points");
pointsMax = data.getNum(0, "points");
for (let i = 0; i < data.getRowCount(); i++) {
let points = data.getNum(i, "points");
let price = data.getNum(i, "price");
priceMin = min(priceMin, price);
priceMax = max(priceMax, price);
pointsMin = min(pointsMin, points);
pointsMax = max(pointsMax, points);
}
}
function draw() {
background(0);
noFill();
stroke(190, 20, 255);
for (let i = 0; i < data.getRowCount(); i++) {
let points = data.get(i, "points");
let price = data.get(i, "price");
let x = map(points, pointsMin, pointsMax, 0, width);
let d = map(price, priceMin, priceMax, 20, width);
ellipse(x, height / 2, d, d);
}
noLoop();
}