Created
September 21, 2013 03:11
-
-
Save phil-pedruco/6646844 to your computer and use it in GitHub Desktop.
NYC Boroughs in d3
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> | |
#boroughs { | |
stroke: grey; | |
stroke-width: 2px; | |
fill: steelblue; | |
} | |
</style> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<body> | |
<script> | |
var width = 960, | |
height = 500; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.json("nyc.json", function(error, nyb) { | |
console.log(nyb) | |
var projection = d3.geo.mercator() | |
.center([-73.94, 40.70]) | |
.scale(50000) | |
.translate([(width) / 2, (height)/2]); | |
var path = d3.geo.path() | |
.projection(projection); | |
var g = svg.append("g"); | |
g.append("g") | |
.attr("id", "boroughs") | |
.selectAll(".state") | |
.data(nyb.features) | |
.enter().append("path") | |
.attr("class", function(d){ return d.properties.name; }) | |
.attr("d", path); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment