Skip to content

Instantly share code, notes, and snippets.

Created April 2, 2014 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save anonymous/9937330 to your computer and use it in GitHub Desktop.
Save anonymous/9937330 to your computer and use it in GitHub Desktop.
{
"libraries": [
"d3",
"TopoJSON"
],
"mode": "javascript",
"layout": "fullscreen mode (vertical)",
"resolution": "reset"
}
.states {
fill: #e5e5e5;
stroke: #fff;
stroke-width:2px;
}
.states:hover {
fill: steelblue;
}
.state {
fill: #e7e7e7;
stroke: #fff;
stroke-width: 2px;
}
.state:hover {
fill: steelblue;
}
<div id="vis"></div>
var width = 760,
height = 500;
var us = livecoding.json;
d3.selectAll("svg").remove();
var svg = d3.select('#vis').append('svg')
.attr('width', width)
.attr('height', height);
var projection = d3.geo.albersUsa()
.scale(900)
.translate([width / 2, height / 2]);
var path = d3.geo.path()
.projection(projection);
function makeMyMap(us){
svg.append('path')
.datum(topojson.feature(us, us.objects.usStates))
.attr('d', path)
.attr('class', 'states');
};
function makeAnotherMap(us) {
svg.selectAll("path")
.data(topojson.feature(us, us.objects.usStates).features)
.enter().append("path")
.attr('d', path)
.attr('class', 'state');
}
makeMyMap(us);
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