Skip to content

Instantly share code, notes, and snippets.

@clayzermk1
Forked from mbostock/.block
Created November 20, 2012 21:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save clayzermk1/4121134 to your computer and use it in GitHub Desktop.
Save clayzermk1/4121134 to your computer and use it in GitHub Desktop.
Mercator Projection
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
<!DOCTYPE html>
<meta charset="utf-8">
<title>Mercator Projection</title>
<style>
path {
fill: #ccc;
stroke: #fff;
}
</style>
<svg width="960" height="500"></svg>
<script src="http://d3js.org/d3.v2.js?2.9.1"></script>
<script>
d3.json("readme.json", function(collection) {
d3.select("svg").selectAll("path")
.data(collection.features)
.enter().append("path")
.attr("d", d3.geo.path().projection(d3.geo.mercator()))
.style("fill", function(d) { return '#'+Math.floor(d.properties.name.charCodeAt(0)/100*4620980).toString(16); });
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment