Built with blockbuilder.org
Last active
September 5, 2017 03:18
-
-
Save stevenwmarks/c3c521915d5b2c7e4956f907525f770c to your computer and use it in GitHub Desktop.
health care $$$ by state
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
license: mit | |
border: no | |
scrolling: yes | |
height: 600 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
state | value | |
---|---|---|
District of Columbia | 11944 | |
Alaska | 11064 | |
Massachusetts | 10559 | |
Delaware | 10254 | |
Vermont | 10190 | |
Connecticut | 9859 | |
North Dakota | 9851 | |
New York | 9778 | |
New Hampshire | 9589 | |
Rhode Island | 9551 | |
Maine | 9531 | |
West Virginia | 9462 | |
Pennsylvania | 9258 | |
South Dakota | 8933 | |
Minnesota | 8871 | |
New Jersey | 8859 | |
Ohio | 8712 | |
Wisconsin | 8702 | |
Maryland | 8602 | |
Nebraska | 8412 | |
Wyoming | 8320 | |
Indiana | 8300 | |
Illinois | 8262 | |
Montana | 8221 | |
Iowa | 8200 | |
Missouri | 8107 | |
Florida | 8076 | |
Michigan | 8055 | |
Oregon | 8044 | |
Kentucky | 8004 | |
Washington | 7913 | |
Louisiana | 7815 | |
Kansas | 7651 | |
Mississippi | 7646 | |
Oklahoma | 7627 | |
Virginia | 7556 | |
California | 7549 | |
Arkansas | 7408 | |
Tennessee | 7372 | |
South Carolina | 7311 | |
Hawaii | 7299 | |
Alabama | 7281 | |
North Carolina | 7264 | |
New Mexico | 7214 | |
Texas | 6998 | |
Idaho | 6927 | |
Colorado | 6804 | |
Nevada | 6714 | |
Georgia | 6587 | |
Arizona | 6452 | |
Utah | 5982 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<script src="https://d3js.org/d3.v4.min.js"></script> | |
<style> | |
body { margin:0;position:fixed;top:0;right:0;bottom:0;left:0; } | |
span { | |
color: white; | |
} | |
</style> | |
</head> | |
<body> | |
<h2>Health Care Expenditures per Capita by State, 2014</h2> | |
<p><span style="background-color:rgb(255,26,26);">Over $10,500</span>.....<span style="background-color:rgb(255,77,77);">$9,000-$10,499</span>..... | |
<span style="background-color:rgb(255,128,128);">$7,500-$8,999</span>.....<span style="background-color:rgb(255,179,179);">$5,950-$7,499</span></p> | |
<div id="map"> | |
<script type="text/javascript"> | |
var width = 910; | |
var height = 475; | |
var projection = d3.geoAlbersUsa() | |
.translate([width/2, height/2]); | |
var path = d3.geoPath() | |
.projection(projection); | |
var svg = d3.select("#map").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.csv("hlthCare.csv", function(error, data) { | |
if(error) throw error; | |
var color = d3.scaleQuantize() | |
.domain([5982, 11944]) | |
.range( | |
[ | |
"rgb(255,179,179)", | |
"rgb(255,128,128)", | |
"rgb(255,77,77)", | |
"rgb(255,26,26)", | |
] | |
); | |
d3.json("https://s3-us-west-2.amazonaws.com/s.cdpn.io/25240/us-states.json", function(error, json) { | |
// merge health expenditures and GeoJSON | |
for (var i = 0, max = data.length; i < max; i++) { | |
// get state name | |
var dataState = data[i].state; | |
// get data value and convert to float | |
var dataValue = parseFloat(data[i].value); | |
// find corresponding state i GeoJSON | |
for(var j = 0, jmax = json.features.length; j < jmax; j++) { | |
jsonState = json.features[j].properties.name; | |
if (dataState == jsonState) { | |
//copy data value into JSON | |
json.features[j].properties.value = dataValue; | |
break; | |
} | |
} | |
} | |
svg.selectAll("path") | |
.data(json.features) | |
.enter() | |
.append("path") | |
.attr("d", path) | |
.style("stroke", "white") | |
.style("fill", function(d) { | |
var value = d.properties.value; | |
if(value) { | |
return color(value); | |
} else { | |
return "#ccc"; | |
} | |
}); | |
}); | |
}); | |
</script> | |
</div> | |
<h5>Source: Henry J. Kaiser Family Foundation</h5> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment