P5.js data visualization

Developer
Size
2,233 Kb
Views
32,384

How do I make an p5.js data visualization?

P5.js data visualization. What is a p5.js data visualization? How do you make a p5.js data visualization? This script and codes were developed by Engin Arslan on 16 December 2022, Friday.

P5.js data visualization Previews

P5.js data visualization - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>p5.js data visualization</title> <link rel="stylesheet" href="css/style.css">
</head>
<body> <html> <head> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.5.7/p5.min.js"></script> </head> <body> </body>
</html> <script src="js/index.js"></script>
</body>
</html>

P5.js data visualization - Script Codes CSS Codes

body { padding: 0; margin: 0; display: -webkit-box; display: -ms-flexbox; display: flex; -webkit-box-pack: center; -ms-flex-pack: center; justify-content: center; -webkit-box-align: center; -ms-flex-align: center; align-items: center; background: black;
}
canvas { position: fixed; top: 50%; left: 50%; -webkit-transform: translate(-50%, -50%); transform: translate(-50%, -50%);
}

P5.js data visualization - Script Codes JS Codes

var data = [];
var maxData;
function setup() { createCanvas(800, 800); angleMode(DEGREES); rectMode(BOTTOM); for (var i = 0; i < 100; i = i + 1) { var randomNumber = random(20, 80); data.push(randomNumber); } maxData = max(data);
}
function draw() { background(43, 53, 63); fill(139, 171, 203); stroke(89, 86, 74); var angleSeparation = 360 / data.length; var padding = 10; if (frameCount <= 400) { maxValue = constrain(frameCount * 2, 0, 400); } else { maxValue = 400; } var offset = 200; var dataMultiplier = (height/2-offset-padding) / maxData; for (var i = 0; i < data.length; i = i + 1) { push(); var currentData = data[i]; var finalHeight = currentData * dataMultiplier; var animatedHeight = map(maxValue, 0, 400, 0, finalHeight); translate(width / 2, height / 2); rotate(angleSeparation * i); rect(0, offset, angleSeparation*2, animatedHeight); text(Math.floor(currentData), offset-20, 0); pop(); }
}
P5.js data visualization - Script Codes
P5.js data visualization - Script Codes
Home Page Home
Developer Engin Arslan
Username enginarslan
Uploaded December 16, 2022
Rating 3
Size 2,233 Kb
Views 32,384
Do you need developer help for P5.js data visualization?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Engin Arslan (enginarslan) Script Codes
Create amazing Facebook ads with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!