Skip to content

Instantly share code, notes, and snippets.

@iros
Created April 2, 2014 18:48
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 iros/9940547 to your computer and use it in GitHub Desktop.
Save iros/9940547 to your computer and use it in GitHub Desktop.
{
"libraries": [
"d3",
"TopoJSON"
],
"mode": "css",
"layout": "fullscreen mode (vertical)",
"resolution": "reset"
}
.state {
fill: #e7e7e7;
stroke: #fff;
stroke-width: 2px;
}
.state:hover {
fill: steelblue;
}
<svg id="map"></svg>
var width = 960,
height = 700;
var svg = d3.select("#map")
.attr("width", width)
.attr("height", height);
var geometry = livecoding.json;
var projection = d3.geo.mercator()
.scale(950)
.translate([width * 2.16, height * 1.5]);
var path = d3.geo.path().projection(projection);
svg.selectAll("path.state")
.data(topojson.feature(geometry, geometry.objects.usStates).features)
.enter()
.append("path")
.attr("d", path)
.classed("state", true);
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment