-
-
Save Andrew-Reid/f4a71ae7a91da13dd9cd9400ff1c074f to your computer and use it in GitHub Desktop.
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> | |
</style> | |
<body> | |
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
<script src="https://d3js.org/topojson.v1.min.js"></script> | |
<script> | |
var width = 500, | |
height = 500; | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
var color = d3.scale.category10(); | |
var projection = d3.geo.albers() | |
.center([0,40.7]) | |
.rotate([74,0]) | |
.translate([width/2,height/2]) | |
.scale(65000); | |
var path = d3.geo.path() | |
.projection(projection); | |
d3.json("ct2010.json", function(error, data) { | |
if (error) return console.error(error); | |
svg.selectAll(".tract") | |
.data(topojson.feature(data, data.objects.nyct2010).features) | |
.enter().append("path") | |
.attr('class','tract') | |
.attr('fill',function(d,i) { return color(d.properties.BoroCode); }) | |
.attr("d", path); | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment