Built with blockbuilder.org
Created
December 2, 2016 18:24
-
-
Save ohdebby/b3284bb4829978e941ff1d29333bb966 to your computer and use it in GitHub Desktop.
Maternal tobacco use
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 |
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 State Code totalBirths2014 deathRate2013 lbw lbwRate preterm pretermRate Births teen teenRate noCollege noCollegeRate noPrenatal noPrenatalRate 4plus 4plusRate tobacco tobaccoRate diabetes diabetesRate Alabama 1 59422 8.6 5989 0.10 6926 0.12 6926 5073 0.09 40776 0.69 1593 0.027 6191 0.10 6367 0.11 2925 0.05 Alaska 2 11392 5.77 672 0.06 967 0.08 967 652 0.06 7528 0.66 95 0.008 1827 0.16 1469 0.13 1032 0.09 Arizona 4 86887 5.25 6086 0.07 7819 0.09 7819 6670 0.08 59500 0.68 1862 0.021 14190 0.16 4675 0.05 6126 0.07 Arkansas 5 38511 7.85 3432 0.09 3845 0.10 3845 3825 0.10 27647 0.72 853 0.022 5028 0.13 5729 0.15 2055 0.05 California 6 502879 4.76 33586 0.07 41594 0.08 41594 27253 0.05 302560 0.60 3176 0.006 59847 0.12 9199 0.02 31762 0.06 Colorado 8 65830 5.12 5769 0.09 5517 0.08 5517 3405 0.05 35401 0.54 1374 0.021 7264 0.11 4399 0.07 3166 0.05 Connecticut 9 36285 4.79 2763 0.08 3347 0.09 3347 1434 0.04 2869 0.08 2551 0.07 Delaware 10 10972 6.37 908 0.08 1019 0.09 1019 627 0.06 6817 0.62 180 0.016 1353 0.12 1185 0.11 957 0.09 District of Columbia 11 9509 6.68 934 0.10 915 0.10 915 573 0.06 4851 0.51 310 0.033 947 0.10 240 0.03 335 0.04 Florida 12 219991 6.14 19065 0.09 21846 0.10 21846 12958 0.06 141325 0.64 2918 0.013 24731 0.11 14064 0.06 11411 0.05 Georgia 13 130946 6.98 12385 0.09 14058 0.11 14058 9762 0.07 83136 0.63 3283 0.025 16792 0.13 7825 0.06 5987 0.05 Hawaii 15 18550 6.37 1462 0.08 1862 0.10 1862 899 0.05 10751 0.58 91 0.005 2491 0.13 883 0.05 Idaho 16 22876 5.63 1471 0.06 1863 0.08 1863 1310 0.06 14532 0.64 202 0.009 4032 0.18 2435 0.11 1177 0.05 Illinois 17 158556 5.97 12929 0.08 16016 0.10 16016 9684 0.06 86677 0.55 1687 0.011 17871 0.11 10676 0.07 10938 0.07 Indiana 18 84080 7.24 6715 0.08 8142 0.10 8142 6283 0.07 54454 0.65 1245 0.015 11396 0.14 12672 0.15 5217 0.06 Iowa 19 39687 4.25 2675 0.07 3677 0.09 3677 2069 0.05 20848 0.53 265 0.007 4998 0.13 5801 0.15 3097 0.08 Kansas 20 39223 6.49 2759 0.07 3423 0.09 3423 2698 0.07 22922 0.58 329 0.008 5596 0.14 4681 0.12 2455 0.06 Kentucky 21 56170 6.39 4922 0.09 6033 0.11 6033 4922 0.09 37530 0.67 678 0.012 6506 0.12 11616 0.21 3412 0.06 Louisiana 22 64497 8.69 6786 0.11 7925 0.12 7925 5368 0.08 45564 0.71 1380 0.021 8110 0.13 4710 0.07 4006 0.06 Maine 23 12698 7.12 960 0.08 1060 0.08 1060 662 0.05 7178 0.57 54 0.004 1101 0.09 2085 0.16 900 0.07 Maryland 24 73921 6.63 6345 0.09 7455 0.10 7455 3430 0.05 39358 0.53 1249 0.017 7661 0.10 5107 0.07 5113 0.07 Massachusetts 25 71908 4.18 5351 0.07 6177 0.09 6177 2421 0.03 31936 0.44 342 0.005 5036 0.07 4431 0.06 4436 0.06 Michigan 26 114375 7.05 9545 0.08 11154 0.10 11154 7036 0.06 71012 0.62 1479 0.013 14080 0.12 15129 0.13 6542 0.06 Minnesota 27 69904 5.09 4595 0.07 6054 0.09 6054 2732 0.04 32110 0.46 360 0.005 9005 0.13 6777 0.10 5057 0.07 Mississippi 28 38736 9.6 4374 0.11 5000 0.13 5000 3925 0.10 26362 0.68 399 0.010 4822 0.12 4317 0.11 1810 0.05 Missouri 29 75360 6.52 6163 0.08 7346 0.10 7346 5283 0.07 46114 0.61 913 0.012 9577 0.13 12475 0.17 4496 0.06 Montana 30 12432 5.57 920 0.07 1157 0.09 1157 813 0.07 7686 0.62 132 0.011 1762 0.14 1954 0.16 578 0.05 Nebraska 31 26794 5.21 1775 0.07 2439 0.09 2439 1411 0.05 14421 0.54 237 0.009 3675 0.14 3050 0.11 1696 0.06 Nevada 32 35861 5.31 2972 0.08 3623 0.10 3623 2474 0.07 25802 0.72 1586 0.044 5441 0.15 1830 0.05 2440 0.07 New Hampshire 33 12302 5.57 852 0.07 1013 0.08 1013 486 0.04 6085 0.49 56 0.005 891 0.07 1650 0.13 861 0.07 New Jersey 34 103305 4.51 8315 0.08 9885 0.10 9885 3729 0.04 10628 0.10 7312 0.07 New Mexico 35 26052 5.27 2282 0.09 2387 0.09 2387 2574 0.10 18613 0.71 602 0.023 3754 0.14 1756 0.07 1653 0.06 New York 36 238773 4.93 18722 0.08 21114 0.09 21114 10056 0.04 130667 0.55 1396 0.006 26357 0.11 12753 0.05 16138 0.07 North Carolina 37 120975 6.99 10720 0.09 11781 0.10 11781 8387 0.07 74912 0.62 2234 0.018 13908 0.11 11893 0.10 7439 0.06 North Dakota 38 11359 6.04 704 0.06 948 0.08 948 570 0.05 5793 0.51 36 0.003 1431 0.13 1638 0.14 642 0.06 Ohio 39 139467 7.33 11800 0.08 14302 0.10 14302 9593 0.07 84880 0.61 2589 0.019 17737 0.13 22594 0.16 10770 0.08 Oklahoma 40 53339 6.73 4238 0.08 5492 0.10 5492 4860 0.09 37352 0.70 984 0.018 7091 0.13 6925 0.13 2792 0.05 Oregon 41 45556 4.94 2842 0.06 3510 0.08 3510 2410 0.05 28135 0.62 335 0.007 5458 0.12 4684 0.10 3966 0.09 Pennsylvania 42 142268 6.65 11713 0.08 13291 0.09 13291 7987 0.06 78727 0.55 2431 0.017 16121 0.11 18939 0.13 8843 0.06 Rhode Island 44 10823 6.48 765 0.07 932 0.09 932 596 0.06 1017 0.09 510 0.05 South Carolina 45 57627 6.87 5435 0.09 6212 0.11 6212 4346 0.08 37463 0.65 642 0.011 6461 0.11 6439 0.11 4372 0.08 South Dakota 46 12283 6.45 804 0.07 1040 0.08 1040 742 0.06 7168 0.58 98 0.008 1999 0.16 1807 0.15 1017 0.08 Tennessee 47 81602 6.8 7297 0.09 8780 0.11 8780 6832 0.08 54959 0.67 1361 0.017 9703 0.12 12127 0.15 5482 0.07 Texas 48 399766 5.82 32744 0.08 41345 0.10 41345 35533 0.09 277257 0.69 14067 0.035 52472 0.13 15687 0.04 22113 0.06 Utah 49 51154 5.18 3572 0.07 4678 0.09 4678 2180 0.04 27778 0.54 234 0.005 10372 0.20 1966 0.04 2871 0.06 Vermont 50 6130 4.35 432 0.07 486 0.08 486 308 0.05 3224 0.53 15 0.002 491 0.08 1024 0.17 329 0.05 Virginia 51 103300 6.18 8130 0.08 9517 0.09 9517 4920 0.05 55264 0.53 698 0.007 10375 0.10 5726 0.06 5659 0.05 Washington 53 88585 4.53 5705 0.06 7125 0.08 7125 4127 0.05 51263 0.58 796 0.009 10661 0.12 7016 0.08 7343 0.08 West Virginia 54 20301 7.64 1852 0.09 2198 0.11 2198 1997 0.10 13934 0.69 198 0.010 1893 0.09 5400 0.27 1591 0.08 Wisconsin 55 67161 6.26 4911 0.07 6163 0.09 6163 3414 0.05 37182 0.55 361 0.005 8893 0.13 8764 0.13 4926 0.07 Wyoming 56 7696 4.84 704 0.09 863 0.11 863 548 0.07 4737 0.62 201 0.026 1011 0.13 1263 0.16 317 0.04 |
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> | |
<meta charset="utf-8"> | |
<style type="text/css"> | |
body { | |
font-family: arial, sans; | |
font-size: 14px; | |
width: 960px; | |
margin: 40px auto; | |
} | |
svg { | |
border: 1px solid #ccc; | |
} | |
.states { | |
stroke:#fff; | |
fill:none; | |
} | |
.counties { | |
stroke: #fff; | |
fill: green; | |
stroke-width: .3px; | |
} | |
.county-bubble { | |
stroke:#fff; | |
stroke-width: .3; | |
} | |
</style> | |
<body> | |
</body> | |
<script src="http://d3js.org/d3.v4.js" charset="utf-8"></script> | |
<script src="http://d3js.org/topojson.v1.min.js"></script> | |
<script type="text/javascript"> | |
var width = 960, | |
height = 500, | |
color = d3.scaleLinear() | |
.range(["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]) | |
.domain([0.0,0.05,0.10,0.15,0.20,0.25]); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height); | |
d3.queue() | |
.defer(d3.tsv, "birthsState.txt") | |
.defer(d3.json, "us.json") | |
.await(ready); | |
function ready(error, tobacco, us) { | |
if (error) return console.warn(error); | |
console.log(tobacco); | |
console.log(us); | |
console.log(topojson.feature(us, us.objects.states).features); | |
tobaccoByState = {}; | |
tobacco.forEach(function(d) { | |
d["prenatalRate"] = +d["tobaccoRate"]; | |
tobaccoByState[+d["State Code"]] = d; | |
}); | |
var path = d3.geoPath() | |
.projection(d3.geoAlbersUsa()); | |
var subset = topojson.feature(us, us.objects.states).features.filter(function(d) { | |
return d.id in tobaccoByState; | |
}); | |
svg.append("g") | |
.attr("class", "states") | |
.selectAll("path") | |
.data(subset) | |
.enter().append("path") | |
.attr("d", path) | |
.style("fill", function(d) { | |
return color(tobaccoByState[d.id]["tobaccoRate"]) | |
}); | |
svg.append("path") | |
.datum(topojson.mesh(us, us.objects.states, function(a, b) { return a.id !== b.id; })) | |
.attr("class", "states") | |
.attr("d", path); | |
svg.append("text") | |
.style("font-weight", "bold") | |
.attr("x", width - 170) | |
.attr("y", height - 158) | |
.text("% maternal tobacco use"); | |
var legend = svg.selectAll(".legend") | |
.data(color.domain()) | |
.enter().append("g") | |
.attr("transform", function(d,i) { | |
return "translate(" + (width-160) + "," + (height - 150 + 16 * i) + ")"; | |
}) | |
.on("click", function(min,i) { | |
console.log(min,i); | |
}); | |
legend.append("rect") | |
.attr("width", 12) | |
.attr("height", 12) | |
.style("fill", function(d) { | |
return color(d); | |
}); | |
legend.append("text") | |
.attr("x", 16) | |
.attr("y", 7) | |
.attr("alignment-baseline", "middle") | |
.style("font-size", "12px") | |
.text(function(d) { | |
return (d*10).toFixed(1)+"%"; | |
}); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment