Skip to content

Instantly share code, notes, and snippets.

@etachov
Created April 6, 2015 22:08
Show Gist options
  • Save etachov/d407c675d3d25bdb3e45 to your computer and use it in GitHub Desktop.
Save etachov/d407c675d3d25bdb3e45 to your computer and use it in GitHub Desktop.
country objective disbursed
Kenya Counterterrorism 5297145.2
Mali Counterterrorism 4920931.2
Egypt Counterterrorism 2628123
Morocco Counterterrorism 1500857
Pakistan Counterterrorism 1493790
Colombia Counterterrorism 1287168
Uganda Counterterrorism 1094019
Yemen Counterterrorism 1005153
Afghanistan Counterterrorism 869230
Jordan Counterterrorism 801724
Hungary Counterterrorism 785354
Indonesia Counterterrorism 772915
Lebanon Counterterrorism 767163
Nigeria Counterterrorism 759686
Turkey Counterterrorism 692781
Philippines Counterterrorism 681213.8
Mexico Counterterrorism 613661
Bulgaria Counterterrorism 544967
India Counterterrorism 529612
Brazil Counterterrorism 514855
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset = "utf-8">
<title>US Counterterrorism Assistance</title>
<script type = "text/javascript" src = "http://d3js.org/d3.v3.js"></script>
<style type = "text/css">
body {
background-color: #fff;
font-family: sans-serif;
}
svg {
background-color: #fff;
}
</style>
</head>
<body>
<p>Top 20 Recipients of <strong>U.S. Counterterrorism Assistance</strong> in 2013</p>
<script type = "text/javascript">
var svg = d3.select("body")
.append("svg")
.attr("width", 600)
.attr("height", 1200);
d3.csv("ct_aid.csv", function(data) {
data.sort(function(a, b) {
return d3.descending(+a.disbursed, +b.disbursed);
});
console.log(data)
var rects = svg.selectAll("rect")
.data(data)
.enter()
.append("rect")
.attr("fill", "#2a3439");
rects.attr("x", 0)
.attr("y", function(d, i) {
return i * 20;
})
.attr("width", function(d) {
return d.disbursed / 10000;
})
.attr("height", 16)
.append("title")
.text(function(d) {
return d.country + " received $" + d.disbursed + " in counterterrorism aid in 2013";
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment