Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save emamut/f5210249c5ef7216cc2e to your computer and use it in GitHub Desktop.
Save emamut/f5210249c5ef7216cc2e to your computer and use it in GitHub Desktop.
Conventional telephony (TTUP vs CDMA) users in Ecuador by province
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Conventional telephony users in Ecuador by province</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<style type="text/css">
body {
background-color: white;
font-family: Helvetica, Arial, sans-serif;
}
h1 {
font-size: 24px;
margin: 0;
}
p {
font-size: 14px;
margin: 10px 0 0 0;
}
svg {
background-color: white;
}
circle:hover {
fill: steelblue;
}
.axis path,
.axis line {
fill: none;
stroke: black;
shape-rendering: crispEdges;
}
.axis text {
font-family: sans-serif;
font-size: 11px;
}
</style>
</head>
<body>
<h1>Conventional telephony (TTUP vs CDMA) users in Ecuador by province</h1>
<p>TTUP conventional telephony users by province. Source: <a href="http://datosabiertos.gob.ec/catalogo/es/dataset/total-de-abonados-suscriptores-de-telefonia-fija-por-provincia">Datos Abiertos</a>, Julio 2015</p>
<script>
var width = 700;
var height = 400;
var padding = [ 20, 10, 20, 130 ];
var xScale = d3.scale.linear()
.range([padding[3], width - padding[1]]);
var yScale = d3.scale.linear()
.range([padding[0], height - padding[2]]);
var x_axis = d3.svg.axis()
.scale(xScale)
.orient('bottom');
var y_axis = d3.svg.axis()
.scale(yScale)
.orient('left');
var svg = d3.select('body')
.append('svg')
.attr('width', width)
.attr('height', height);
d3.csv('Total de Abonados (Suscriptores) de Telefonía Fija por Provincia.csv', function(response) {
response.sort(function (a, b) {
return d3.descending(+a.TTUP, +b.TTUP);
});
xScale.domain([0, d3.max(response, function (d) {
return +d.TTUP;
})]);
yScale.domain([0, d3.max(response, function (d) {
return +d.CDMA;
})]);
var circles = svg.selectAll('circle')
.data(response)
.enter()
.append('circle')
circles.attr('cx', function (value){
return xScale(value.TTUP);
})
.attr('cy', function (value) {
return xScale(value.CDMA);
})
.attr('r', 5)
.attr("fill", "red")
.append('title')
.text(function (value) {
return 'Abonados en ' + value.provincia + ' (TTUP: ' + value.TTUP + ' CDMA: ' + value.CDMA + ')'
});
svg.append('g')
.attr('class', 'x axis')
.attr('transform', "translate(0," + (height - padding[2]) + ")")
.call(x_axis);
svg.append('g')
.attr('class', 'y axis')
.attr('transform', "translate(" + (padding[3]) + ",0)")
.call(y_axis);
});
</script>
</body>
</html>
anho mes provincia convencional CDMA TTUP
2015 Julio AZUAY 153133 25617 691
2015 Julio BOLIVAR 16054 5025 175
2015 Julio CANAR 24413 5711 11
2015 Julio CARCHI 21383 3057 203
2015 Julio CHIMBORAZO 56245 5743 536
2015 Julio COTOPAXI 44158 2024 242
2015 Julio EL ORO 78584 2716 200
2015 Julio ESMERALDAS 39202 3765 300
2015 Julio GALAPAGOS 5125 2886 2
2015 Julio GUAYAS 600702 2191 3209
2015 Julio IMBABURA 63712 4363 935
2015 Julio LOJA 55848 10167 202
2015 Julio LOS RIOS 45210 643 28
2015 Julio MANABI 103623 5998 179
2015 Julio MORONA SANTIAGO 14513 5965 144
2015 Julio NAPO 10593 1707 153
2015 Julio ORELLANA 10546 1642 104
2015 Julio PASTAZA 12695 1513 147
2015 Julio PICHINCHA 818165 3841 9874
2015 Julio SANTA ELENA 27926 705 27
2015 Julio SANTO DOMINGO 55479 3941 301
2015 Julio SUCUMBIOS 15895 1876 168
2015 Julio TUNGURAHUA 86466 3175 1033
2015 Julio ZAMORA CHINCHIPE 7725 5492 95
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment