Last active
August 29, 2015 14:01
-
-
Save equivalentideas/b8ac15fd5e5212757f49 to your computer and use it in GitHub Desktop.
Incidents per week time series chart
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
week | count | |
---|---|---|
2009-09-28 | 1 | |
2009-10-19 | 2 | |
2009-10-26 | 6 | |
2009-11-02 | 3 | |
2009-11-09 | 6 | |
2009-11-16 | 22 | |
2009-11-23 | 9 | |
2009-11-30 | 12 | |
2009-12-07 | 13 | |
2009-12-14 | 18 | |
2009-12-21 | 23 | |
2009-12-28 | 16 | |
2010-01-04 | 25 | |
2010-01-11 | 20 | |
2010-01-18 | 23 | |
2010-01-25 | 19 | |
2010-02-01 | 25 | |
2010-02-08 | 18 | |
2010-02-15 | 16 | |
2010-02-22 | 20 | |
2010-03-01 | 23 | |
2010-03-08 | 24 | |
2010-03-15 | 16 | |
2010-03-22 | 28 | |
2010-03-29 | 27 | |
2010-04-05 | 37 | |
2010-04-12 | 27 | |
2010-04-19 | 32 | |
2010-04-26 | 41 | |
2010-05-03 | 46 | |
2010-05-10 | 37 | |
2010-05-17 | 42 | |
2010-05-24 | 36 | |
2010-05-31 | 48 | |
2010-06-07 | 44 | |
2010-06-14 | 70 | |
2010-06-21 | 52 | |
2010-06-28 | 77 | |
2010-07-05 | 43 | |
2010-07-12 | 52 | |
2010-07-19 | 57 | |
2010-07-26 | 67 | |
2010-08-02 | 49 | |
2010-08-09 | 83 | |
2010-08-16 | 65 | |
2010-08-23 | 76 | |
2010-08-30 | 44 | |
2010-09-06 | 84 | |
2010-09-13 | 82 | |
2010-09-20 | 93 | |
2010-09-27 | 73 | |
2010-10-04 | 73 | |
2010-10-11 | 74 | |
2010-10-18 | 98 | |
2010-10-25 | 103 | |
2010-11-01 | 75 | |
2010-11-08 | 123 | |
2010-11-15 | 140 | |
2010-11-22 | 110 | |
2010-11-29 | 136 | |
2010-12-06 | 110 | |
2010-12-13 | 113 | |
2010-12-20 | 120 | |
2010-12-27 | 120 | |
2011-01-03 | 141 | |
2011-01-10 | 165 | |
2011-01-17 | 164 | |
2011-01-24 | 155 | |
2011-01-31 | 180 | |
2011-02-07 | 187 | |
2011-02-14 | 148 | |
2011-02-21 | 208 | |
2011-02-28 | 279 | |
2011-03-07 | 211 | |
2011-03-14 | 199 | |
2011-03-21 | 140 | |
2011-03-28 | 230 | |
2011-04-04 | 220 | |
2011-04-11 | 182 | |
2011-04-18 | 352 | |
2011-04-25 | 214 | |
2011-05-02 | 261 | |
2011-05-09 | 275 | |
2011-05-16 | 306 | |
2011-05-23 | 148 |
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"> | |
<!-- | |
Based on M Bostock's example http://bl.ocks.org/mbostock/3883245 | |
--> | |
<style> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
.x.axis path { | |
display: none; | |
} | |
.line { | |
fill: none; | |
stroke: steelblue; | |
stroke-width: 1.5px; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.js"></script> | |
<script> | |
var margin = {top: 20, right: 20, bottom: 30, left: 50}, | |
width = 320 - margin.left - margin.right, | |
height = 200 - margin.top - margin.bottom; | |
var parseDate = d3.time.format("%Y-%m-%d").parse; | |
var x = d3.time.scale() | |
.range([0, width]); | |
var y = d3.scale.linear() | |
.range([height, 0]); | |
var xAxis = d3.svg.axis() | |
.scale(x) | |
.orient("bottom"); | |
var yAxis = d3.svg.axis() | |
.scale(y) | |
.orient("left"); | |
var line = d3.svg.line() | |
.x(function(d) { return x(d.week); }) | |
.y(function(d) { return y(d.count); }); | |
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.tsv("data.tsv", function(error, data) { | |
data.forEach(function(d) { | |
d.week = parseDate(d.week); | |
d.count = +d.count; | |
}); | |
x.domain(d3.extent(data, function(d) { return d.week; })); | |
y.domain(d3.extent(data, function(d) { return d.count; })); | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis); | |
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("Incident Report Count"); | |
svg.append("path") | |
.datum(data) | |
.attr("class", "line") | |
.attr("d", line); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment