Skip to content

Instantly share code, notes, and snippets.

@iros
Created Apr 2, 2014
Embed
What would you like to do?
{
"libraries": [
"d3",
"TopoJSON"
],
"mode": "javascript",
"layout": "fullscreen mode (vertical)",
"resolution": "reset"
}
.states {
fill: #e5e5e5;
stroke: #fff;
stroke-width:2px;
}
.states: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.append("path")
.datum(topojson.feature(geometry, geometry.objects.usStates))
.attr("d", path)
.classed("states", true);
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