1 // change the argument to match your id
2 var node = document.getElementById("partidos-map");
3 d3.json("../data/munidata.json", function(data){
4 var party_datamap = {};
5 data.forEach(function(pueblo){
6 //get id of pueblo with leading 0s.
7 var fips_3digits = pueblo.fips.length == 1 ? ("00" + pueblo.fips) :
8 (pueblo.fips.length == 2 ? ("0" + pueblo.fips) : pueblo.fips);
9 party_datamap[fips_3digits] = pueblo.party;
10 });
11 var party_map = new AtlasPR({node: node, size: "large",tiles: 'pueblos', on_ready: function(){
12 // gotta wait until the map is drawn to color it.
13 party_map.encode_qual(party_datamap, {"PPD": "#ff0000", "PNP": "#0000ff"});
14 }});
15 });