Skip to content

Instantly share code, notes, and snippets.

@juanje
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juanje/22958ca5a433178298f0 to your computer and use it in GitHub Desktop.
Save juanje/22958ca5a433178298f0 to your computer and use it in GitHub Desktop.
Playas con bandera azul en España, por regiones
<!doctype html>
<html>
<head>
<title>Playas con bandera azul en España, por regiones</title>
<script src="http://www.chartjs.org/assets/Chart.js"></script>
<meta name = "viewport" content = "initial-scale = 1, user-scalable = no">
<script src="http://libs.cartocdn.com/cartodb.js/v3/cartodb.js"></script>
<style>
canvas{
}
</style>
</head>
<body>
<canvas id="canvas" height="450" width="600"></canvas>
<script>
var sql = cartodb.SQL({ user: 'juanje' });
sql.execute("SELECT region, count(*) as azules FROM juanje.catalogo_de_playas_espana c WHERE aspecto_bandera_azul GROUP BY region ORDER BY azules ASC").done(function(data) {
console.log(data)
var total = [];
var regiones = [];
for (i in data.rows){
total.push(data.rows[i].azules)
regiones.push(data.rows[i].region)
}
console.log(data)
var lineChartData = {
labels : regiones,
datasets : [
{
fillColor : "rgba(151,187,205,0.5)",
strokeColor : "rgba(151,187,205,1)",
pointColor : "rgba(151,187,205,1)",
pointStrokeColor : "#fff",
data : total
}
]
}
var myLine = new Chart(document.getElementById("canvas").getContext("2d")).Line(lineChartData);
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment