Skip to content

Instantly share code, notes, and snippets.

@junkwhinger
Last active August 29, 2015 14:25
Show Gist options
  • Save junkwhinger/af220b7dfee792d34ce2 to your computer and use it in GitHub Desktop.
Save junkwhinger/af220b7dfee792d34ce2 to your computer and use it in GitHub Desktop.
The Hacking Team: # of emails regarding 'SKA' - 2,112 emails
date freq
2008-07 1
2010-08 9
2010-09 26
2010-10 3
2010-11 21
2010-12 7
2011-01 2
2011-02 7
2011-03 5
2011-05 5
2011-06 6
2011-07 7
2011-08 14
2011-09 7
2011-10 29
2011-11 20
2011-12 125
2012-01 102
2012-02 37
2012-03 23
2012-04 32
2012-05 99
2012-06 23
2012-07 76
2012-08 53
2012-09 31
2012-11 1
2012-12 14
2013-01 58
2013-02 74
2013-03 37
2013-04 21
2013-05 8
2013-07 1
2013-08 14
2013-09 67
2013-10 32
2013-11 18
2013-12 41
2014-01 53
2014-02 57
2014-03 108
2014-04 13
2014-05 6
2014-06 15
2014-07 21
2014-08 13
2014-09 16
2014-10 4
2014-11 52
2014-12 146
2015-01 81
2015-02 44
2015-03 59
2015-04 19
2015-05 10
2015-06 145
2015-07 94
<!DOCTYPE html>
<meta charset="utf-8">
<head><h1>The Hacking Team: # of emails regarding 'SKA' - 2,112 emails</h1></head>
<style>
body {
font: 10px sans-serif;
}
.axis {
font: 11px sans-serif;
}
.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script>
var margin = {top: 20, right: 20, bottom: 70, left: 40},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
// Parse the date / time
var parseDate = d3.time.format("%Y-%m").parse;
var x = d3.time.scale().range([0, width])
var x2 = d3.time.scale().range([0, width])
var y = d3.scale.linear().range([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.tickFormat(d3.time.format("%Y-%m"))
.ticks(20);
var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.ticks(10);
var svg = d3.select("body").append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform",
"translate(" + margin.left + "," + margin.top + ")");
d3.csv("data.csv", function(error, data) {
data.forEach(function(d) {
d.date = parseDate(d.date);
d.value = +d.freq;
});
console.log(d3.extent(data, function(d){ return d.date}))
x.domain(d3.extent(data, function(d){ return d.date}))
y.domain([0, d3.max(data, function(d) { return d.value; })]);
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll("text")
.style("text-anchor", "end")
.attr("dx", "-.8em")
.attr("dy", "-.55em")
.attr("transform", "rotate(-90)" );
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("# of emails sent");
svg.selectAll("bar")
.data(data)
.enter().append("rect")
.style("fill", "steelblue")
.attr("x", function(d) { return x(d.date); })
.attr("width", 5)
.attr("y", function(d) { return y(d.value); })
.attr("height", function(d) { return height - y(d.value); })
.on("mouseover", function(d,i) {
d3.select(this)
.style("fill", "red")
})
.on("mouseout", function(d,i) {
d3.select(this)
.style("fill", "steelblue")
})
});
</script>
</body>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment