Last active
August 29, 2015 14:00
-
-
Save aaizemberg/11100889 to your computer and use it in GitHub Desktop.
Población por provincia (usando html5 canvas)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset=utf-8 /> | |
<title>Población de Argentina por provincia (censo 2010)</title> | |
</head> | |
<body> | |
<canvas id="myCanvas" width="600" height="400" style="border:1px solid #aaa;"> | |
</canvas> | |
<script> | |
var canvas = document.getElementById('myCanvas'); | |
var context = canvas.getContext('2d'); | |
var poblacion = [15625084, 3308876, 3194537, 2890151, 1738929, 1448188, 1235994, 1214441, 1101593, 1055259, 992595, 874006, 681055, 673307, 638645, 551266, 530162, 509108, 432310, 367828, 333642, 318951, 273964, 127205]; | |
context.beginPath(); | |
context.lineWidth = 1; | |
context.strokeStyle = 'white'; | |
for (var i=0; i < poblacion.length; i++) { | |
context.rect(10, 10+(canvas.height/(poblacion.length+1)*i), (canvas.width-20)* poblacion[i]/poblacion[0], canvas.height/(poblacion.length+1)); | |
context.fillStyle = 'grey'; | |
context.fill(); | |
} | |
context.stroke(); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment