-
Notifications
You must be signed in to change notification settings - Fork 20
/
population.html
42 lines (42 loc) · 1.41 KB
/
population.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
---
layout: default
---
<h3>Pueblos - Población en el 2012</h3>
<div id = 'poblacion-map'>
</div>
<script type = 'text/javascript'>
var node = document.getElementById("poblacion-map");
d3.json("data/munidata.json", function(data){
var pop_datamap = {};
//use FIPS code as key
data.forEach(function(pueblo){
//get id of pueblo with leading 0s.
var fips_3digits = pueblo.fips.length == 1 ? ("00" + pueblo.fips) :
(pueblo.fips.length == 2 ? ("0" + pueblo.fips) : pueblo.fips);
pop_datamap[fips_3digits] = pueblo.population;
});
var pop_map = new AtlasPR({node: node, size: "large", tiles: 'pueblos', on_ready: function(){
pop_map.encode_quan(pop_datamap);
}});
});
</script>
<div id = "code">
{% highlight js linenos %}
// change the argument to match your id
var node = document.getElementById("poblacion-map");
d3.json("data/munidata.json", function(data){
var pop_datamap = {};
//use FIPS code as key
data.forEach(function(pueblo){
//get id of pueblo with leading 0s.
var fips_3digits = pueblo.fips.length == 1 ? ("00" + pueblo.fips) :
(pueblo.fips.length == 2 ? ("0" + pueblo.fips) : pueblo.fips);
pop_datamap[fips_3digits] = pueblo.population;
});
var pop_map = new AtlasPR({node: node, size: "large", tiles: 'pueblos', on_ready: function(){
// paint after drawing async.
pop_map.encode_quan(pop_datamap);
}});
});
{% endhighlight %}
</div>