Skip to content

Instantly share code, notes, and snippets.

@sarubenfeld
Created October 6, 2016 19:47
Show Gist options
  • Save sarubenfeld/07e575969ca5fb2a8fcd2af9acb4a4bd to your computer and use it in GitHub Desktop.
Save sarubenfeld/07e575969ca5fb2a8fcd2af9acb4a4bd to your computer and use it in GitHub Desktop.
SF Evictions: Condo Conversion
date condo neighborhoods
99 2016-06-24 True Outer Richmond
423 2007-03-14 True Haight Ashbury
534 2003-10-06 True Potrero Hill
930 2013-09-30 True Marina
1315 2001-06-28 True Hayes Valley
1650 2015-07-24 True Pacific Heights
2011 2011-12-30 True Hayes Valley
2261 2015-04-14 True Castro/Upper Market
2378 2012-04-10 True Inner Sunset
2501 2010-12-02 True Potrero Hill
3023 2013-06-10 True Castro/Upper Market
4309 2004-04-07 True Presidio Heights
4440 2014-07-22 True Hayes Valley
4675 2014-02-19 True Castro/Upper Market
5233 2002-04-22 True Western Addition
5302 2000-01-04 True Nob Hill
5437 2006-05-15 True Hayes Valley
5750 2014-05-27 True Bernal Heights
5764 1999-08-02 True Glen Park
6738 2013-08-12 True Lone Mountain/USF
7274 2013-06-14 True Marina
7342 2009-02-18 True Noe Valley
7473 2012-08-27 True Chinatown
7613 2002-09-13 True Presidio Heights
8241 2004-07-02 True Castro/Upper Market
8688 2015-08-04 True Outer Richmond
9023 2015-07-24 True Pacific Heights
9212 2007-01-29 True Outer Richmond
9311 2000-02-08 True Noe Valley
9561 2001-03-01 True Haight Ashbury
9631 2016-02-08 True North Beach
10356 2001-12-19 True Hayes Valley
10439 2013-12-16 True Inner Sunset
10526 2003-02-18 True
10871 2012-11-28 True Bernal Heights
10903 2009-02-09 True South of Market
11385 2003-03-17 True Castro/Upper Market
11429 2001-05-14 True Castro/Upper Market
11515 2013-11-04 True Noe Valley
11688 1997-06-18 True Pacific Heights
11922 2016-03-31 True Hayes Valley
12395 2012-08-27 True Chinatown
12583 2004-07-06 True Pacific Heights
12930 2015-11-05 True Castro/Upper Market
13256 2003-08-06 True Mission
13333 2010-06-10 True Western Addition
14276 2013-10-03 True Inner Sunset
14482 2002-05-30 True Mission
15579 2013-10-03 True Inner Sunset
15896 2012-03-09 True Marina
16243 2002-06-25 True Hayes Valley
16442 2006-10-16 True Inner Sunset
17182 1999-07-29 True Glen Park
17214 2004-07-02 True Castro/Upper Market
17996 2000-02-06 True Castro/Upper Market
18070 2015-10-16 True Marina
18171 2015-11-05 True Castro/Upper Market
18436 2015-08-13 True Castro/Upper Market
18526 2004-07-30 True Pacific Heights
19375 2015-06-12 True Bernal Heights
19475 2012-04-11 True Hayes Valley
20448 2007-08-09 True Inner Sunset
20767 2013-10-17 True
20948 2004-07-30 True Pacific Heights
21070 2015-11-05 True Castro/Upper Market
21853 2001-09-18 True Pacific Heights
22940 2015-07-02 True Castro/Upper Market
23502 2000-02-06 True Castro/Upper Market
23709 2004-07-27 True Castro/Upper Market
23976 2001-06-14 True Hayes Valley
24224 2012-08-22 True Mission
24259 2014-12-10 True Russian Hill
25918 2008-11-07 True Hayes Valley
26007 2015-07-24 True Pacific Heights
26340 2003-02-18 True Haight Ashbury
26507 2015-07-24 True Pacific Heights
27351 2015-10-16 True Marina
27503 2012-08-27 True Chinatown
27549 2012-06-15 True Russian Hill
27728 2008-02-04 True Noe Valley
27768 2016-05-02 True North Beach
27851 2015-08-13 True Castro/Upper Market
27923 2003-02-18 True Haight Ashbury
28085 2015-08-13 True Castro/Upper Market
28104 2010-07-01 True Lone Mountain/USF
28192 2003-01-06 True Mission
28985 2014-10-01 True North Beach
29642 2015-07-24 True Pacific Heights
30556 2015-06-22 True Haight Ashbury
30583 2011-03-31 True Russian Hill
30610 2014-05-07 True Hayes Valley
30729 2013-06-20 True Noe Valley
31477 2014-04-18 True Presidio Heights
31627 2016-04-07 True Noe Valley
31649 2004-07-30 True Pacific Heights
32208 2001-01-24 True Lone Mountain/USF
32565 2012-02-29 True Russian Hill
32808 2006-10-16 True Inner Sunset
33038 2012-07-30 True Noe Valley
33973 2014-10-27 True Pacific Heights
34019 2003-01-30 True Inner Sunset
34230 2014-12-03 True Russian Hill
34490 2013-10-03 True Inner Sunset
34661 2013-04-02 True Mission
34984 1998-02-25 True Pacific Heights
35232 2010-06-01 True Glen Park
35769 2014-05-27 True Bernal Heights
<!DOCTYPE html>
<meta charset="utf-8">
<style>
h1, h2, h3, h4, h5, h6 {
font-family: futura;
color: grey;
}
.bar rect {
fill: #00B8A9;
}
.bar text {
fill: #fff;
font-family:Futura;
font-size: 10px;
}
.axis text {
font-family: Futura
}
.axis line {
stroke: #00B8A9;
stroke-dasharray: 2, 2;
stroke-linecap: "round";
shape-rendering: crispEdges;
}
</style>
<body>
<div class="g-chart-container">
<h2> SF Evictions: Condo Conversion </h2>
</div>
<script src="//d3js.org/d3.v4.min.js"></script>
<script>
var parseDate = d3.timeParse("%Y-%m-%d"),
formatCount = d3.format(",.0f");
var margin = {top: 10, right: 30, bottom: 30, left: 30},
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.scaleTime()
.domain([new Date(1998, 1, 0), new Date(2016, 1, 0)])
.rangeRound([0, width]);
var y = d3.scaleLinear()
.range([height, 0]);
var histogram = d3.histogram()
.value(function(d) { return d.date; })
.domain(x.domain());
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 + ")");
svg.append("g")
.attr("class", "axis axis--x")
.attr("transform", "translate(0," + height + ")")
.call(d3.axisBottom(x));
d3.csv("cc_cleaned.csv", type, function(error, data) {
if (error) throw error;
var bins = histogram(data);
y.domain([0, d3.max(bins, function(d) { return d.length; })]);
var bar = svg.selectAll(".bar")
.data(bins)
.enter().append("g")
.attr("class", "bar")
.attr("transform", function(d) { return "translate(" + x(d.x0) + "," + y(d.length) + ")"; });
bar.append("rect")
.attr("x", 1)
.attr("width", function(d) { return x(d.x1) - x(d.x0) - 1; })
.attr("height", function(d) { return height - y(d.length); });
bar.append("text")
.attr("dy", ".75em")
.attr("y", 6)
.attr("x", function(d) { return (x(d.x1) - x(d.x0)) / 2; })
.attr("text-anchor", "middle")
.text(function(d) { return formatCount(d.length); });
});
function type(d) {
d.date = parseDate(d.date);
return d;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment