Skip to content

Instantly share code, notes, and snippets.

@darrenjaworski
Last active December 16, 2015 06:09
Show Gist options
  • Save darrenjaworski/5389527 to your computer and use it in GitHub Desktop.
Save darrenjaworski/5389527 to your computer and use it in GitHub Desktop.
US choropleth - Medicaid Expansion Status

This is a choropleth map of the US using datamaps that shows the medicaid expansion status of each state. Originally created in Google Fusion and published on Oklahoma Watch, this is a more advanced and aesthetically pleasing version.

<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: #ccc;
stroke: #fff;
}
path:hover {
fill: red;
}
#container1 {
width: 960px;
height: 500px;
}
#container2 {
width: 960px;
height: 500px;
}
</style>
<body>
<div id="container1"></div>
<script src="http://datamaps.github.com/scripts/datamaps-all.js"></script>
<script>
var map = new Map({
scope : 'usa',
el : $('#container1'),
geography_config : {
highlightBorderColor : '#222',
highlightOnHover : true,
popupTemplate : _.template('<div class="hoverinfo"><strong><%= geography.properties.name %></strong> <% if (data.expansionStatus) { %><hr/> Expansion Status: <%= data.expansionStatus %> <% } %></div>')
},
//#CC4731 red - not expanding
//#EAA9A8 light red -lean not expanding
//#cccccc ThirdWorst - undecided
//#A9C0DE light FifthWorst - lean expanding
//'#306596 FifthWorst - expanding
fills : {
'NOTEXPANDING' : '#CC4731',
'LEANNOTEXPANDING' : '#EAA9A8',
'UNDECIDED' : '#cccccc',
'LEANEXPANDING' : '#A9C0DE',
'EXPANDING' : '#306596',
defaultFill : '#EDDC4E'
},
data : {
"AL" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 14.3,
'ranking' : 20
},
"AK" : {
"fillKey" : "LEANNOTEXPANDING",
"expansionStatus" : 'Leaning against expansion',
'percentUninsured' : 18.2,
'ranking' : 10
},
"AZ" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 18.2,
'ranking' : 10
},
"AR" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 18,
'ranking' : 11
},
"CA" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 19.6,
'ranking' : 7
},
"CO" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 14.3,
'ranking' : 20
},
"CT" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 9.9,
'ranking' : 36
},
"DE" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 10.7,
'ranking' : 34
},
"FL" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 20.2,
'ranking' : 5
},
"GA" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 19.3,
'ranking' : 8
},
"HI" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 7.8,
'ranking' : 40
},
"ID" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 18,
'ranking' : 11
},
"IL" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 14.8,
'ranking' : 17
},
"IN" : {
"fillKey" : "UNDECIDED",
"expansionStatus" : 'Expanding',
'percentUninsured' : 12.7,
'ranking' : 29
},
"IA" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 11.1,
'ranking' : 32
},
"KS" : {
"fillKey" : "UNDECIDED",
"expansionStatus" : 'Expanding',
'percentUninsured' : 13.1,
'ranking' : 26
},
"KY" : {
"fillKey" : "LEANEXPANDING",
"expansionStatus" : 'Leaning toward expanding',
'percentUninsured' : 14.6,
'ranking' : 18
},
"LA" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 20.3,
'ranking' : 4
},
"MD" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 13.3,
'ranking' : 25
},
"ME" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 9.7,
'ranking' : 37
},
"MA" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 4.5,
'ranking' : 41
},
"MN" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 9.5,
'ranking' : 38
},
"MI" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 12.7,
'ranking' : 29
},
"MS" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 18.6,
'ranking' : 9
},
"MO" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 14.4,
'ranking' : 19
},
"MT" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 18.2,
'ranking' : 10
},
"NC" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 16.7,
'ranking' : 14
},
"NE" : {
"fillKey" : "LEANNOTEXPANDING",
"expansionStatus" : 'Leaning against expansion',
'percentUninsured' : 12.8,
'ranking' : 28
},
"NV" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 22,
'ranking' : 2
},
"NH" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 11.3,
'ranking' : 31
},
"NJ" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 15.5,
'ranking' : 15
},
"NY" : {
"fillKey" : "LEANEXPANDING",
"expansionStatus" : 'Leaning toward expanding',
'percentUninsured' : 13.6,
'ranking' : 24
},
"ND" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 11.3,
'ranking' : 31
},
"NM" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 20.5,
'ranking' : 3
},
"OH" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 13.7,
'ranking' : 23
},
"OK" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 17.1,
'ranking' : 13
},
"OR" : {
"fillKey" : "LEANEXPANDING",
"expansionStatus" : 'Leaning toward expanding',
'percentUninsured' : 14.9,
'ranking' : 16
},
"PA" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 10.9,
'ranking' : 33
},
"RI" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 11.8,
'ranking' : 30
},
"SC" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 19.7,
'ranking' : 6
},
"SD" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 13,
'ranking' : 27
},
"TN" : {
"fillKey" : "UNDECIDED",
"expansionStatus" : 'Undecided',
'percentUninsured' : 13.9,
'ranking' : 22
},
"TX" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 24.2,
'ranking' : 1
},
"UT" : {
"fillKey" : "UNDECIDED",
"expansionStatus" : 'Undecided',
'percentUninsured' : 14.2,
'ranking' : 21
},
"VT" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 9,
'ranking' : 39
},
"VA" : {
"fillKey" : "UNDECIDED",
"expansionStatus" : 'Undecided',
'percentUninsured' : 13.7,
'ranking' : 23
},
"WV" : {
"fillKey" : "UNDECIDED",
"expansionStatus" : 'Undecided',
'percentUninsured' : 14.2,
'ranking' : 21
},
"WA" : {
"fillKey" : "EXPANDING",
"expansionStatus" : 'Expanding',
'percentUninsured' : 14.2,
'ranking' : 21
},
"WI" : {
"fillKey" : "NOTEXPANDING",
"expansionStatus" : 'Not expanding',
'percentUninsured' : 9.9,
'ranking' : 36
},
"WY" : {
"fillKey" : "LEANNOTEXPANDING",
"expansionStatus" : 'Leaning against expansion',
'percentUninsured' : 17.5,
'ranking' : 12
},
}
});
map.render();
</script>
</body>
</html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment