Skip to content

Instantly share code, notes, and snippets.

@squarednob
Forked from minikomi/index.html
Last active December 30, 2015 09:09
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 squarednob/7807200 to your computer and use it in GitHub Desktop.
Save squarednob/7807200 to your computer and use it in GitHub Desktop.
Japan's geojson and D3 code.
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">
<body>
<script src="http://d3js.org/d3.v2.min.js?2.10.0"></script>
<script>
var width = 960,
height = 700;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
var xym = d3.geo.albers();
var path = d3.geo.path().projection(xym);
xym.origin([134, 25])
xym.translate([350, 745])
xym.parallels([24.6, 43.6])
xym.scale(1980)
d3.json("japan.json", function(data) {
svg.selectAll("path").data(data.features)
.enter().append("path")
.attr("d", path)
.style("fill", function() { return "#44aaee" })
.on("mouseover", function(e){d3.select(this).style("fill", "#5522aa")})
.on("mouseout", function(e){d3.select(this).style("fill", "#44aaee")})
});
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment