-
-
Save djvanderlaan/73833ec90a8a77b0e29f 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> | |
<html> | |
<head> | |
<meta charset="utf-8" /> | |
<script src="http://d3js.org/d3.v3.min.js"></script> | |
</head> | |
<body> | |
<div id="vis"></div> | |
<script> | |
// Map properties | |
var xmin = 13565.400; | |
var xmax = 306846.900; | |
var ymin = 277992.800; | |
var ymax = 619305.599; | |
var height = 400; | |
var scale = height/(ymax - ymin); | |
var width = Math.ceil((xmax - xmin) * scale); | |
projection = function(coordinates) { | |
return [ scale*(coordinates[0]-xmin), | |
height-scale*(coordinates[1]-ymin) ]; | |
} | |
var path = d3.geo.path().projection(projection); | |
var vis = d3.select("#vis").append("svg") | |
.attr("width", width).attr("height", height) | |
d3.json("po_2012_simplified.json", function(json) { | |
vis.selectAll("path").data(json.features).enter().append("path") | |
.attr("d", path) | |
.style("fill", "red") | |
.style("stroke-width", "1") | |
.style("stroke", "black") | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment