Sourced from the 2012 DC Bicycle Count Summary, visualized with d3js.
Created
December 10, 2012 23:10
-
-
Save tmcw/4254216 to your computer and use it in GitHub Desktop.
Ratio of Average Bikers versus Miles of Bike Lanes 2004-2012
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> | |
body { | |
font: 10px sans-serif; | |
} | |
.axis path, | |
.axis line { | |
fill: none; | |
stroke: #000; | |
shape-rendering: crispEdges; | |
} | |
path.line { | |
stroke-width:4; | |
fill:none; | |
stroke:darkblue; | |
} | |
</style> | |
<body> | |
<script src="http://d3js.org/d3.v3.js"></script> | |
<script> | |
var margin = {top: 20, right: 20, bottom: 30, left: 50}, | |
width = 960 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
var parseDate = d3.time.format("%Y").parse, | |
formatPercent = d3.format(".0%"); | |
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") | |
.tickFormat(formatPercent); | |
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 + ")"); | |
var line = d3.svg.line() | |
.x(function(d) { return x(d.date); }) | |
.y(function(d) { return y(d.ratio); }); | |
d3.csv("peak.csv", function(error, data) { | |
data.forEach(function(d) { | |
d.date = parseDate(d.year); | |
d.ratio = +d['Peak Hour'] / +d['Miles of Bike Lanes']; | |
}); | |
x.domain(d3.extent(data, function(d) { return d.date; })); | |
y.domain(d3.extent(data, function(d) { return d.ratio; })); | |
var l = svg.selectAll(".browser") | |
.data([data]) | |
.enter().append("g") | |
.attr("class", "browser"); | |
l.append("path") | |
.attr("class", "line") | |
.attr("d", line); | |
svg.append("g") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis); | |
svg.append("g") | |
.attr("class", "y axis") | |
.call(yAxis); | |
}); | |
</script> |
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
year | Peak Hour | Miles of Bike Lanes | |
---|---|---|---|
2004 | 34.5 | 14 | |
2005 | 38.2 | 19 | |
2006 | 41.2 | 25 | |
2007 | 39.6 | 30 | |
2008 | 52.9 | 39 | |
2009 | 65.6 | 45 | |
2010 | 71.9 | 50 | |
2011 | 86.8 | 51 | |
2012 | 94.8 | 57 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment