Skip to content

Instantly share code, notes, and snippets.

@aaizemberg
Last active August 29, 2015 14:00
Show Gist options
  • Save aaizemberg/11100889 to your computer and use it in GitHub Desktop.
Save aaizemberg/11100889 to your computer and use it in GitHub Desktop.
Población por provincia (usando html5 canvas)
<!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