Skip to content

Instantly share code, notes, and snippets.

@werbeckes
Last active May 18, 2017 03:08
Show Gist options
  • Select an option

  • Save werbeckes/8e76346b564546e1f100a5847979edd0 to your computer and use it in GitHub Desktop.

Select an option

Save werbeckes/8e76346b564546e1f100a5847979edd0 to your computer and use it in GitHub Desktop.
SLP Stats Map
<!DOCTYPE html>
<html lang="en">
<head>
<script src="http://d3js.org/d3.v3.min.js"></script>
<style>
.state{
fill: none;
stroke: #a9a9a9;
stroke-width: 1;
}
.state:hover{
fill-opacity:0.5;
}
</style>
</head>
<body>
<script type="text/javascript">
var width = 960;
var height = 500;
var projection = d3.geo.albersUsa()
.translate([width/2, height/2]) // translate to center of screen
.scale([1000]); // scale things down so see entire US
var path = d3.geo.path().projection(projection);
var svg = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height);
var states = svg.append( "g" )
.attr("class", "states");
//var geoPath = d3.geo.path().projection( albersProjection );
//g.selectAll( "path" )
// .data( us_json )
// .enter()
// .append( "path" )
// .attr( "fill", "#ccc" )
// .attr( "d", geoPath );
d3.json("./us.json", function (collection) {
states.selectAll("path")
.data(collection.features)
.enter().append("path")
.attr("class","state")
.attr("d", path);
});
</script>
</body>
</html>
Alabama 19
Alaska 1
Arkansas 26
Arizona 49
California 214
Colorado 41
Connecticut 35
Delaware 13
Florida 79
Georgia 83
Hawaii 2
Iowa 27
Idaho 13
Illinois 163
Indiana 90
Kansas 44
Kentucky 30
Louisiana 15
Maine 11
Maryland 51
Massachusetts 70
Michigan 80
Minnesota 63
Missouri 102
Mississippi 21
Montana 11
North Carolina 60
North Dakota 19
Nebraska 38
New Hampshire 20
New Jersey 102
New Mexico 19
Nevada 9
New York 144
Ohio 120
Oklahoma 64
Oregon 25
Pennsylvania 112
Rhode Island 7
South Carolina 29
South Dakota 14
Tennessee 46
Texas 192
Utah 19
Virginia 78
Vermont 10
Washington 40
Wisconsin 124
West Virginia 8
Wyoming 10
Display the source blob
Display the rendered blob
Raw
Loading
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