Skip to content

Instantly share code, notes, and snippets.

@mango314
Last active December 14, 2015 07:59
Show Gist options
  • Save mango314/5054700 to your computer and use it in GitHub Desktop.
Save mango314/5054700 to your computer and use it in GitHub Desktop.
a map of Puerto Rico by county
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/queue.v1.min.js"></script>
<style>
svg{ background-color:#FEFEFE;}
.stroke {
fill: none;
stroke: #000;
stroke-width: .5px;
}
</style>
</head>
<body>
<script>
var width=1250, height=500;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var q = 0;
var sc = 500;
var d3line2 = d3.svg.line()
.x(function(d){q= 0.95105*sc*(d[0]+67.5262); return q;})
.y(function(d){q= sc*(-1*d[1]+ 18.6336); return q;})
.interpolate("linear");
d3.json("/prCounties.json", function(d){
for(var k = 0; k < d.features[0].length; k++){
//http://stackoverflow.com/questions/15124600/d3-js-trouble-parsing-mnan-nan
svg.append("path")
.attr("d", d3line2(d.features[0][k].geometry.coordinates[0][0].concat([d.features[0][k].geometry.coordinates[0][0][0]])) )
.attr("class", "stroke");
}
});
</script>
</body>
</html>
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment