Last active
August 29, 2015 14:01
-
-
Save josecarlosgonz/0ce2a73795c9d12eff9d to your computer and use it in GitHub Desktop.
Map of Mexican States
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.states { | |
fill: #222; | |
} | |
.states :hover { | |
fill: orange; | |
} | |
</style> | |
<body> | |
<script type="text/javascript" src = "javascripts/d3.js"></script> | |
<script type="text/javascript" src = "javascripts/topojson.js"></script> | |
<script> | |
var width = 960, | |
height = 628; | |
var path = d3.geo.path() | |
.projection(null); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.json("states.json", function(error, mx) { | |
console.log("Map area") | |
svg.append("g") | |
.attr("class", "states") | |
.selectAll("path") | |
.data(topojson.feature(mx, mx.objects.shp_vic).features) | |
.enter().append("path") | |
.attr("d", path) | |
.append("title") | |
.text(function(d) { return d.properties.NOM_ENT; }); | |
}); | |
d3.select(self.frameElement).style("height", height + "px"); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment