Skip to content

Instantly share code, notes, and snippets.

@josecarlosgonz
Created June 1, 2014 20:45
Show Gist options
  • Save josecarlosgonz/38eccc82e09c20840579 to your computer and use it in GitHub Desktop.
Save josecarlosgonz/38eccc82e09c20840579 to your computer and use it in GitHub Desktop.
<!doctype HTML>
<meta charset = 'utf-8'>
<html>
<head>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
<script src='http://d3js.org/d3.v3.min.js' type='text/javascript'></script>
<script src='http://d3js.org/topojson.v1.min.js' type='text/javascript'></script>
<script src='http://datamaps.github.io/scripts/datamaps.all.min.js' type='text/javascript'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min.js' type='text/javascript'></script>
<script src='http://cdnjs.cloudflare.com/ajax/libs/angular.js/1.2.1/angular.min.js' type='text/javascript'></script>
<style>
.rChart {
display: block;
margin-left: auto;
margin-right: auto;
width: 800px;
height: 400px;
}
.container {
margin-top: 20px;
}
</style>
</head>
<body ng-app ng-controller='rChartsCtrl'>
<div class='container'>
<div class="btn-group" >
<button ng-repeat="value in years" ng-click='updateYear(value)'
class="btn btn-default" type="button"
ng-model="value" btn-radio="value">
{{ value }}
</button>
</div>
<div id='chart_1' class='rChart datamaps'></div>
</div>
<script>
function rChartsCtrl($scope){
$scope.years = [2010, 2011, 2012]
$scope.year = $scope.years[0]
$scope.updateYear = function(x){
$scope.year = x
}
$scope.$watch('year', function(newYear){
mapchart_1.updateChoropleth(chartParams.newData[newYear]);
})
}
</script>
<script id='popup-template' type='text/x-handlebars-template'>
</script>
<script>
var chartParams = {
"dom": "chart_1",
"width": 800,
"height": 400,
"geographyConfig": {
"dataUrl": "mx_states.json",
"popupTemplate": function(geography, data) { //this function should just return a string
return '<div class=hoverinfo><strong>' + geography.properties.name + '</strong></div>';
}
},
"scope": "states",
"labels": true,
"bodyattrs": "ng-app ng-controller='rChartsCtrl'",
"setProjection": function( element, options ) {
var projection, path;
projection = d3.geo.mercator()
.center([-89, 21])
.scale(element.offsetWidth)
.translate([element.offsetWidth / 2, element.offsetHeight / 2]);
path = d3.geo.path()
.projection( projection );
return {path: path, projection: projection};
} ,
"fills": {
"[12592,18289]": "#FFFFB2",
"(18289,23986]": "#FECC5C",
"(23986,29683]": "#FD8D3C",
"(29683,35380]": "#F03B20",
"(35380,41076]": "#BD0026",
"defaultFill": "#BD0026"
},
"data": {
"Aguascalientes": {
"state_code": 1,
"short_name": "AGU",
"name": "Aguascalientes",
"year": 2010,
"prevalencia": 36387,
"fillKey": "(35380,41076]"
},
"Baja California": {
"state_code": 2,
"short_name": "BCN",
"name": "Baja California",
"year": 2010,
"prevalencia": 30753,
"fillKey": "(29683,35380]"
},
"Baja California Sur": {
"state_code": 3,
"short_name": "BCS",
"name": "Baja California Sur",
"year": 2010,
"prevalencia": 23328,
"fillKey": "(18289,23986]"
},
"Campeche": {
"state_code": 4,
"short_name": "CAM",
"name": "Campeche",
"year": 2010,
"prevalencia": 17321,
"fillKey": "[12592,18289]"
},
"Coahuila de Zaragoza": {
"state_code": 5,
"short_name": "COA",
"name": "Coahuila de Zaragoza",
"year": 2010,
"prevalencia": 25250,
"fillKey": "(23986,29683]"
},
"Colima": {
"state_code": 6,
"short_name": "COL",
"name": "Colima",
"year": 2010,
"prevalencia": 17138,
"fillKey": "[12592,18289]"
},
"Chiapas": {
"state_code": 7,
"short_name": "CHP",
"name": "Chiapas",
"year": 2010,
"prevalencia": 12856,
"fillKey": "[12592,18289]"
},
"Chihuahua": {
"state_code": 8,
"short_name": "CHH",
"name": "Chihuahua",
"year": 2010,
"prevalencia": 34826,
"fillKey": "(29683,35380]"
},
"Distrito Federal": {
"state_code": 9,
"short_name": "DIF",
"name": "Distrito Federal",
"year": 2010,
"prevalencia": 32495,
"fillKey": "(29683,35380]"
},
"Durango": {
"state_code": 10,
"short_name": "DUR",
"name": "Durango",
"year": 2010,
"prevalencia": 20598,
"fillKey": "(18289,23986]"
},
"Guanajuato": {
"state_code": 11,
"short_name": "GUA",
"name": "Guanajuato",
"year": 2010,
"prevalencia": 20890,
"fillKey": "(18289,23986]"
},
"Guerrero": {
"state_code": 12,
"short_name": "GRO",
"name": "Guerrero",
"year": 2010,
"prevalencia": 20172,
"fillKey": "(18289,23986]"
},
"Hidalgo": {
"state_code": 13,
"short_name": "HID",
"name": "Hidalgo",
"year": 2010,
"prevalencia": 20699,
"fillKey": "(18289,23986]"
},
"Jalisco": {
"state_code": 14,
"short_name": "JAL",
"name": "Jalisco",
"year": 2010,
"prevalencia": 24452,
"fillKey": "(23986,29683]"
},
"Estado de México": {
"state_code": 15,
"short_name": "MEX",
"name": "Estado de México",
"year": 2010,
"prevalencia": 27908,
"fillKey": "(23986,29683]"
},
"Michoacán de Ocampo": {
"state_code": 16,
"short_name": "MIC",
"name": "Michoacán de Ocampo",
"year": 2010,
"prevalencia": 14931,
"fillKey": "[12592,18289]"
},
"Morelos": {
"state_code": 17,
"short_name": "MOR",
"name": "Morelos",
"year": 2010,
"prevalencia": 21925,
"fillKey": "(18289,23986]"
},
"Nayarit": {
"state_code": 18,
"short_name": "NAY",
"name": "Nayarit",
"year": 2010,
"prevalencia": 23224,
"fillKey": "(18289,23986]"
},
"Nuevo León": {
"state_code": 19,
"short_name": "NLE",
"name": "Nuevo León",
"year": 2010,
"prevalencia": 27310,
"fillKey": "(23986,29683]"
},
"Oaxaca": {
"state_code": 20,
"short_name": "OAX",
"name": "Oaxaca",
"year": 2010,
"prevalencia": 16262,
"fillKey": "[12592,18289]"
},
"Puebla": {
"state_code": 21,
"short_name": "PUE",
"name": "Puebla",
"year": 2010,
"prevalencia": 21707,
"fillKey": "(18289,23986]"
},
"Querétaro": {
"state_code": 22,
"short_name": "QUE",
"name": "Querétaro",
"year": 2010,
"prevalencia": 19675,
"fillKey": "(18289,23986]"
},
"Quintana Roo": {
"state_code": 23,
"short_name": "QROO",
"name": "Quintana Roo",
"year": 2010,
"prevalencia": 28740,
"fillKey": "(23986,29683]"
},
"San Luis Potosí": {
"state_code": 24,
"short_name": "SLP",
"name": "San Luis Potosí",
"year": 2010,
"prevalencia": 22636,
"fillKey": "(18289,23986]"
},
"Sinaloa": {
"state_code": 25,
"short_name": "SIN",
"name": "Sinaloa",
"year": 2010,
"prevalencia": 26373,
"fillKey": "(23986,29683]"
},
"Sonora": {
"state_code": 26,
"short_name": "SON",
"name": "Sonora",
"year": 2010,
"prevalencia": 29285,
"fillKey": "(23986,29683]"
},
"Tabasco": {
"state_code": 27,
"short_name": "TAB",
"name": "Tabasco",
"year": 2010,
"prevalencia": 25074,
"fillKey": "(23986,29683]"
},
"Tamaulipas": {
"state_code": 28,
"short_name": "TAM",
"name": "Tamaulipas",
"year": 2010,
"prevalencia": 22647,
"fillKey": "(18289,23986]"
},
"Tlaxcala": {
"state_code": 29,
"short_name": "TLA",
"name": "Tlaxcala",
"year": 2010,
"prevalencia": 20721,
"fillKey": "(18289,23986]"
},
"Veracruz de Ignacio de la Llave": {
"state_code": 30,
"short_name": "VER",
"name": "Veracruz de Ignacio de la Llave",
"year": 2010,
"prevalencia": 16437,
"fillKey": "[12592,18289]"
},
"Yucatán": {
"state_code": 31,
"short_name": "YUC",
"name": "Yucatán",
"year": 2010,
"prevalencia": 17826,
"fillKey": "[12592,18289]"
},
"Zacatecas": {
"state_code": 32,
"short_name": "ZAC",
"name": "Zacatecas",
"year": 2010,
"prevalencia": 22747,
"fillKey": "(18289,23986]"
}
},
"legend": true,
"id": "chart_1",
"newData": {
"2010": {
"Aguascalientes": {
"state_code": 1,
"short_name": "AGU",
"name": "Aguascalientes",
"year": 2010,
"prevalencia": 36387,
"fillKey": "(35380,41076]"
},
"Baja California": {
"state_code": 2,
"short_name": "BCN",
"name": "Baja California",
"year": 2010,
"prevalencia": 30753,
"fillKey": "(29683,35380]"
},
"Baja California Sur": {
"state_code": 3,
"short_name": "BCS",
"name": "Baja California Sur",
"year": 2010,
"prevalencia": 23328,
"fillKey": "(18289,23986]"
},
"Campeche": {
"state_code": 4,
"short_name": "CAM",
"name": "Campeche",
"year": 2010,
"prevalencia": 17321,
"fillKey": "[12592,18289]"
},
"Coahuila de Zaragoza": {
"state_code": 5,
"short_name": "COA",
"name": "Coahuila de Zaragoza",
"year": 2010,
"prevalencia": 25250,
"fillKey": "(23986,29683]"
},
"Colima": {
"state_code": 6,
"short_name": "COL",
"name": "Colima",
"year": 2010,
"prevalencia": 17138,
"fillKey": "[12592,18289]"
},
"Chiapas": {
"state_code": 7,
"short_name": "CHP",
"name": "Chiapas",
"year": 2010,
"prevalencia": 12856,
"fillKey": "[12592,18289]"
},
"Chihuahua": {
"state_code": 8,
"short_name": "CHH",
"name": "Chihuahua",
"year": 2010,
"prevalencia": 34826,
"fillKey": "(29683,35380]"
},
"Distrito Federal": {
"state_code": 9,
"short_name": "DIF",
"name": "Distrito Federal",
"year": 2010,
"prevalencia": 32495,
"fillKey": "(29683,35380]"
},
"Durango": {
"state_code": 10,
"short_name": "DUR",
"name": "Durango",
"year": 2010,
"prevalencia": 20598,
"fillKey": "(18289,23986]"
},
"Guanajuato": {
"state_code": 11,
"short_name": "GUA",
"name": "Guanajuato",
"year": 2010,
"prevalencia": 20890,
"fillKey": "(18289,23986]"
},
"Guerrero": {
"state_code": 12,
"short_name": "GRO",
"name": "Guerrero",
"year": 2010,
"prevalencia": 20172,
"fillKey": "(18289,23986]"
},
"Hidalgo": {
"state_code": 13,
"short_name": "HID",
"name": "Hidalgo",
"year": 2010,
"prevalencia": 20699,
"fillKey": "(18289,23986]"
},
"Jalisco": {
"state_code": 14,
"short_name": "JAL",
"name": "Jalisco",
"year": 2010,
"prevalencia": 24452,
"fillKey": "(23986,29683]"
},
"Estado de México": {
"state_code": 15,
"short_name": "MEX",
"name": "Estado de México",
"year": 2010,
"prevalencia": 27908,
"fillKey": "(23986,29683]"
},
"Michoacán de Ocampo": {
"state_code": 16,
"short_name": "MIC",
"name": "Michoacán de Ocampo",
"year": 2010,
"prevalencia": 14931,
"fillKey": "[12592,18289]"
},
"Morelos": {
"state_code": 17,
"short_name": "MOR",
"name": "Morelos",
"year": 2010,
"prevalencia": 21925,
"fillKey": "(18289,23986]"
},
"Nayarit": {
"state_code": 18,
"short_name": "NAY",
"name": "Nayarit",
"year": 2010,
"prevalencia": 23224,
"fillKey": "(18289,23986]"
},
"Nuevo León": {
"state_code": 19,
"short_name": "NLE",
"name": "Nuevo León",
"year": 2010,
"prevalencia": 27310,
"fillKey": "(23986,29683]"
},
"Oaxaca": {
"state_code": 20,
"short_name": "OAX",
"name": "Oaxaca",
"year": 2010,
"prevalencia": 16262,
"fillKey": "[12592,18289]"
},
"Puebla": {
"state_code": 21,
"short_name": "PUE",
"name": "Puebla",
"year": 2010,
"prevalencia": 21707,
"fillKey": "(18289,23986]"
},
"Querétaro": {
"state_code": 22,
"short_name": "QUE",
"name": "Querétaro",
"year": 2010,
"prevalencia": 19675,
"fillKey": "(18289,23986]"
},
"Quintana Roo": {
"state_code": 23,
"short_name": "QROO",
"name": "Quintana Roo",
"year": 2010,
"prevalencia": 28740,
"fillKey": "(23986,29683]"
},
"San Luis Potosí": {
"state_code": 24,
"short_name": "SLP",
"name": "San Luis Potosí",
"year": 2010,
"prevalencia": 22636,
"fillKey": "(18289,23986]"
},
"Sinaloa": {
"state_code": 25,
"short_name": "SIN",
"name": "Sinaloa",
"year": 2010,
"prevalencia": 26373,
"fillKey": "(23986,29683]"
},
"Sonora": {
"state_code": 26,
"short_name": "SON",
"name": "Sonora",
"year": 2010,
"prevalencia": 29285,
"fillKey": "(23986,29683]"
},
"Tabasco": {
"state_code": 27,
"short_name": "TAB",
"name": "Tabasco",
"year": 2010,
"prevalencia": 25074,
"fillKey": "(23986,29683]"
},
"Tamaulipas": {
"state_code": 28,
"short_name": "TAM",
"name": "Tamaulipas",
"year": 2010,
"prevalencia": 22647,
"fillKey": "(18289,23986]"
},
"Tlaxcala": {
"state_code": 29,
"short_name": "TLA",
"name": "Tlaxcala",
"year": 2010,
"prevalencia": 20721,
"fillKey": "(18289,23986]"
},
"Veracruz de Ignacio de la Llave": {
"state_code": 30,
"short_name": "VER",
"name": "Veracruz de Ignacio de la Llave",
"year": 2010,
"prevalencia": 16437,
"fillKey": "[12592,18289]"
},
"Yucatán": {
"state_code": 31,
"short_name": "YUC",
"name": "Yucatán",
"year": 2010,
"prevalencia": 17826,
"fillKey": "[12592,18289]"
},
"Zacatecas": {
"state_code": 32,
"short_name": "ZAC",
"name": "Zacatecas",
"year": 2010,
"prevalencia": 22747,
"fillKey": "(18289,23986]"
}
},
"2011": {
"Aguascalientes": {
"state_code": 1,
"short_name": "AGU",
"name": "Aguascalientes",
"year": 2011,
"prevalencia": 25665,
"fillKey": "(23986,29683]"
},
"Baja California": {
"state_code": 2,
"short_name": "BCN",
"name": "Baja California",
"year": 2011,
"prevalencia": 30588,
"fillKey": "(29683,35380]"
},
"Baja California Sur": {
"state_code": 3,
"short_name": "BCS",
"name": "Baja California Sur",
"year": 2011,
"prevalencia": 27019,
"fillKey": "(23986,29683]"
},
"Campeche": {
"state_code": 4,
"short_name": "CAM",
"name": "Campeche",
"year": 2011,
"prevalencia": 17280,
"fillKey": "[12592,18289]"
},
"Coahuila de Zaragoza": {
"state_code": 5,
"short_name": "COA",
"name": "Coahuila de Zaragoza",
"year": 2011,
"prevalencia": 22945,
"fillKey": "(18289,23986]"
},
"Colima": {
"state_code": 6,
"short_name": "COL",
"name": "Colima",
"year": 2011,
"prevalencia": 22193,
"fillKey": "(18289,23986]"
},
"Chiapas": {
"state_code": 7,
"short_name": "CHP",
"name": "Chiapas",
"year": 2011,
"prevalencia": 12621,
"fillKey": "[12592,18289]"
},
"Chihuahua": {
"state_code": 8,
"short_name": "CHH",
"name": "Chihuahua",
"year": 2011,
"prevalencia": 30455,
"fillKey": "(29683,35380]"
},
"Distrito Federal": {
"state_code": 9,
"short_name": "DIF",
"name": "Distrito Federal",
"year": 2011,
"prevalencia": 33256,
"fillKey": "(29683,35380]"
},
"Durango": {
"state_code": 10,
"short_name": "DUR",
"name": "Durango",
"year": 2011,
"prevalencia": 20111,
"fillKey": "(18289,23986]"
},
"Guanajuato": {
"state_code": 11,
"short_name": "GUA",
"name": "Guanajuato",
"year": 2011,
"prevalencia": 24753,
"fillKey": "(23986,29683]"
},
"Guerrero": {
"state_code": 12,
"short_name": "GRO",
"name": "Guerrero",
"year": 2011,
"prevalencia": 20497,
"fillKey": "(18289,23986]"
},
"Hidalgo": {
"state_code": 13,
"short_name": "HID",
"name": "Hidalgo",
"year": 2011,
"prevalencia": 21821,
"fillKey": "(18289,23986]"
},
"Jalisco": {
"state_code": 14,
"short_name": "JAL",
"name": "Jalisco",
"year": 2011,
"prevalencia": 26181,
"fillKey": "(23986,29683]"
},
"Estado de México": {
"state_code": 15,
"short_name": "MEX",
"name": "Estado de México",
"year": 2011,
"prevalencia": 31018,
"fillKey": "(29683,35380]"
},
"Michoacán de Ocampo": {
"state_code": 16,
"short_name": "MIC",
"name": "Michoacán de Ocampo",
"year": 2011,
"prevalencia": 21040,
"fillKey": "(18289,23986]"
},
"Morelos": {
"state_code": 17,
"short_name": "MOR",
"name": "Morelos",
"year": 2011,
"prevalencia": 22982,
"fillKey": "(18289,23986]"
},
"Nayarit": {
"state_code": 18,
"short_name": "NAY",
"name": "Nayarit",
"year": 2011,
"prevalencia": 20877,
"fillKey": "(18289,23986]"
},
"Nuevo León": {
"state_code": 19,
"short_name": "NLE",
"name": "Nuevo León",
"year": 2011,
"prevalencia": 24991,
"fillKey": "(23986,29683]"
},
"Oaxaca": {
"state_code": 20,
"short_name": "OAX",
"name": "Oaxaca",
"year": 2011,
"prevalencia": 18129,
"fillKey": "[12592,18289]"
},
"Puebla": {
"state_code": 21,
"short_name": "PUE",
"name": "Puebla",
"year": 2011,
"prevalencia": 23053,
"fillKey": "(18289,23986]"
},
"Querétaro": {
"state_code": 22,
"short_name": "QUE",
"name": "Querétaro",
"year": 2011,
"prevalencia": 21576,
"fillKey": "(18289,23986]"
},
"Quintana Roo": {
"state_code": 23,
"short_name": "QROO",
"name": "Quintana Roo",
"year": 2011,
"prevalencia": 26829,
"fillKey": "(23986,29683]"
},
"San Luis Potosí": {
"state_code": 24,
"short_name": "SLP",
"name": "San Luis Potosí",
"year": 2011,
"prevalencia": 24847,
"fillKey": "(23986,29683]"
},
"Sinaloa": {
"state_code": 25,
"short_name": "SIN",
"name": "Sinaloa",
"year": 2011,
"prevalencia": 23948,
"fillKey": "(18289,23986]"
},
"Sonora": {
"state_code": 26,
"short_name": "SON",
"name": "Sonora",
"year": 2011,
"prevalencia": 29974,
"fillKey": "(29683,35380]"
},
"Tabasco": {
"state_code": 27,
"short_name": "TAB",
"name": "Tabasco",
"year": 2011,
"prevalencia": 19612,
"fillKey": "(18289,23986]"
},
"Tamaulipas": {
"state_code": 28,
"short_name": "TAM",
"name": "Tamaulipas",
"year": 2011,
"prevalencia": 18126,
"fillKey": "[12592,18289]"
},
"Tlaxcala": {
"state_code": 29,
"short_name": "TLA",
"name": "Tlaxcala",
"year": 2011,
"prevalencia": 18362,
"fillKey": "(18289,23986]"
},
"Veracruz de Ignacio de la Llave": {
"state_code": 30,
"short_name": "VER",
"name": "Veracruz de Ignacio de la Llave",
"year": 2011,
"prevalencia": 17820,
"fillKey": "[12592,18289]"
},
"Yucatán": {
"state_code": 31,
"short_name": "YUC",
"name": "Yucatán",
"year": 2011,
"prevalencia": 14832,
"fillKey": "[12592,18289]"
},
"Zacatecas": {
"state_code": 32,
"short_name": "ZAC",
"name": "Zacatecas",
"year": 2011,
"prevalencia": 21146,
"fillKey": "(18289,23986]"
}
},
"2012": {
"Aguascalientes": {
"state_code": 1,
"short_name": "AGU",
"name": "Aguascalientes",
"year": 2012,
"prevalencia": 27225,
"fillKey": "(23986,29683]"
},
"Baja California": {
"state_code": 2,
"short_name": "BCN",
"name": "Baja California",
"year": 2012,
"prevalencia": 36579,
"fillKey": "(35380,41076]"
},
"Baja California Sur": {
"state_code": 3,
"short_name": "BCS",
"name": "Baja California Sur",
"year": 2012,
"prevalencia": 27043,
"fillKey": "(23986,29683]"
},
"Campeche": {
"state_code": 4,
"short_name": "CAM",
"name": "Campeche",
"year": 2012,
"prevalencia": 21991,
"fillKey": "(18289,23986]"
},
"Coahuila de Zaragoza": {
"state_code": 5,
"short_name": "COA",
"name": "Coahuila de Zaragoza",
"year": 2012,
"prevalencia": 19540,
"fillKey": "(18289,23986]"
},
"Colima": {
"state_code": 6,
"short_name": "COL",
"name": "Colima",
"year": 2012,
"prevalencia": 24908,
"fillKey": "(23986,29683]"
},
"Chiapas": {
"state_code": 7,
"short_name": "CHP",
"name": "Chiapas",
"year": 2012,
"prevalencia": 12620,
"fillKey": "[12592,18289]"
},
"Chihuahua": {
"state_code": 8,
"short_name": "CHH",
"name": "Chihuahua",
"year": 2012,
"prevalencia": 32567,
"fillKey": "(29683,35380]"
},
"Distrito Federal": {
"state_code": 9,
"short_name": "DIF",
"name": "Distrito Federal",
"year": 2012,
"prevalencia": 31675,
"fillKey": "(29683,35380]"
},
"Durango": {
"state_code": 10,
"short_name": "DUR",
"name": "Durango",
"year": 2012,
"prevalencia": 24232,
"fillKey": "(23986,29683]"
},
"Guanajuato": {
"state_code": 11,
"short_name": "GUA",
"name": "Guanajuato",
"year": 2012,
"prevalencia": 28861,
"fillKey": "(23986,29683]"
},
"Guerrero": {
"state_code": 12,
"short_name": "GRO",
"name": "Guerrero",
"year": 2012,
"prevalencia": 26789,
"fillKey": "(23986,29683]"
},
"Hidalgo": {
"state_code": 13,
"short_name": "HID",
"name": "Hidalgo",
"year": 2012,
"prevalencia": 19451,
"fillKey": "(18289,23986]"
},
"Jalisco": {
"state_code": 14,
"short_name": "JAL",
"name": "Jalisco",
"year": 2012,
"prevalencia": 31861,
"fillKey": "(29683,35380]"
},
"Estado de México": {
"state_code": 15,
"short_name": "MEX",
"name": "Estado de México",
"year": 2012,
"prevalencia": 41048,
"fillKey": "(35380,41076]"
},
"Michoacán de Ocampo": {
"state_code": 16,
"short_name": "MIC",
"name": "Michoacán de Ocampo",
"year": 2012,
"prevalencia": 20354,
"fillKey": "(18289,23986]"
},
"Morelos": {
"state_code": 17,
"short_name": "MOR",
"name": "Morelos",
"year": 2012,
"prevalencia": 29310,
"fillKey": "(23986,29683]"
},
"Nayarit": {
"state_code": 18,
"short_name": "NAY",
"name": "Nayarit",
"year": 2012,
"prevalencia": 19169,
"fillKey": "(18289,23986]"
},
"Nuevo León": {
"state_code": 19,
"short_name": "NLE",
"name": "Nuevo León",
"year": 2012,
"prevalencia": 31316,
"fillKey": "(29683,35380]"
},
"Oaxaca": {
"state_code": 20,
"short_name": "OAX",
"name": "Oaxaca",
"year": 2012,
"prevalencia": 14335,
"fillKey": "[12592,18289]"
},
"Puebla": {
"state_code": 21,
"short_name": "PUE",
"name": "Puebla",
"year": 2012,
"prevalencia": 22733,
"fillKey": "(18289,23986]"
},
"Querétaro": {
"state_code": 22,
"short_name": "QUE",
"name": "Querétaro",
"year": 2012,
"prevalencia": 24002,
"fillKey": "(23986,29683]"
},
"Quintana Roo": {
"state_code": 23,
"short_name": "QROO",
"name": "Quintana Roo",
"year": 2012,
"prevalencia": 29703,
"fillKey": "(29683,35380]"
},
"San Luis Potosí": {
"state_code": 24,
"short_name": "SLP",
"name": "San Luis Potosí",
"year": 2012,
"prevalencia": 26810,
"fillKey": "(23986,29683]"
},
"Sinaloa": {
"state_code": 25,
"short_name": "SIN",
"name": "Sinaloa",
"year": 2012,
"prevalencia": 26141,
"fillKey": "(23986,29683]"
},
"Sonora": {
"state_code": 26,
"short_name": "SON",
"name": "Sonora",
"year": 2012,
"prevalencia": 29131,
"fillKey": "(23986,29683]"
},
"Tabasco": {
"state_code": 27,
"short_name": "TAB",
"name": "Tabasco",
"year": 2012,
"prevalencia": 20837,
"fillKey": "(18289,23986]"
},
"Tamaulipas": {
"state_code": 28,
"short_name": "TAM",
"name": "Tamaulipas",
"year": 2012,
"prevalencia": 21407,
"fillKey": "(18289,23986]"
},
"Tlaxcala": {
"state_code": 29,
"short_name": "TLA",
"name": "Tlaxcala",
"year": 2012,
"prevalencia": 18150,
"fillKey": "[12592,18289]"
},
"Veracruz de Ignacio de la Llave": {
"state_code": 30,
"short_name": "VER",
"name": "Veracruz de Ignacio de la Llave",
"year": 2012,
"prevalencia": 18733,
"fillKey": "(18289,23986]"
},
"Yucatán": {
"state_code": 31,
"short_name": "YUC",
"name": "Yucatán",
"year": 2012,
"prevalencia": 19548,
"fillKey": "(18289,23986]"
},
"Zacatecas": {
"state_code": 32,
"short_name": "ZAC",
"name": "Zacatecas",
"year": 2012,
"prevalencia": 20337,
"fillKey": "(18289,23986]"
}
}
}
}
chartParams.element = document.getElementById('chart_1')
var mapchart_1 = new Datamap(chartParams);
// draw a bubble map if specified
if (chartParams.bubbles) {
var bubbles = chartParams.bubbles
mapchart_1.bubbles(bubbles)
}
if (chartParams.labels){
mapchart_1.labels()
}
if (chartParams.legend){
mapchart_1.legend()
}
setProjection = function( element, options ) {
var projection, path;
projection = d3.geo.albersUsa()
.scale(element.offsetWidth)
.translate([element.offsetWidth / 2, element.offsetHeight / 2]);
path = d3.geo.path()
.projection( projection );
return {path: path, projection: projection};
}
</script>
<style>
.datamaps {
position: relative;
}
</style>
<script></script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment