Skip to content

Instantly share code, notes, and snippets.

@arfon
Last active June 24, 2016 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arfon/52475b14a19b831e3df5fe93669081ed to your computer and use it in GitHub Desktop.
Save arfon/52475b14a19b831e3df5fe93669081ed to your computer and use it in GitHub Desktop.
Jekyll GitHub Activity
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<style>
body {
font: 12px sans-serif;
color: #121401;
padding-bottom: 30px;
}
.axis path,
.axis line {
fill: none;
stroke: #121401;
stroke-width: 2px;
shape-rendering: crispEdges;
}
.point {
stroke: grey;
stroke-width: 3px;
opacity: 0;
}
.x.label {
font-size: 16px;
font-weight: normal;
}
.y.label {
font-size: 16px;
font-weight: normal;
}
.x.label.year{
font-size: 12px;
font-weight: normal;
}
.attribution{
font-size: 16px;
font-weight: normal;
}
</style>
</head>
<body>
<h2 style="font-size:18px;text-align:center;margin-left:-260px">jekyll/jekyll activity</h2>
<script src="https://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="https://code.jquery.com/jquery-2.2.4.min.js" integrity="sha256-BbhdlvQf/xTY9gja0Dq3HiwQF8LaCRTXxZKRutelT44=" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
function toTitleCase(str)
{
return str.replace(/\w\S*/g, function(txt){return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();});
}
var margin = {top: 20, right: 55, bottom: 100, left: 90},
width = 1100 - margin.left - margin.right,
height = 700 - margin.top - margin.bottom;
var x = d3.scale.ordinal()
.rangeRoundBands([0, width], .1);
var y = d3.scale.linear()
.rangeRound([height, 0]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom")
.tickValues(['2009-01','2010-01','2011-01', '2012-01', '2013-01','2014-01', '2015-01','2016-01']);
var yAxis = d3.svg.axis()
.scale(y)
.orient("left");
var stack = d3.layout.stack()
.offset("zero")
.values(function (d) { return d.values; })
.x(function (d) { return x(d.label) + x.rangeBand() / 2; })
.y(function (d) { return d.value; });
var area = d3.svg.area()
.interpolate("cardinal")
.x(function (d) { return x(d.label) + x.rangeBand() / 2; })
.y0(function (d) { return y(d.y0); })
.y1(function (d) { return y(d.y0 + d.y); });
var color = d3.scale.ordinal()
.range(["#f4a460","#6495ed","#0c457d","#8b8878","#f46066","#188cef"]);
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("summary.csv", function (error, data) {
var labelVar = 'year_week';
var varNames = d3.keys(data[0])
.filter(function (key) { return key !== labelVar;});
color.domain(varNames);
var seriesArr = [], series = {};
varNames.forEach(function (name) {
series[name] = {name: name, values:[]};
seriesArr.push(series[name]);
});
data.forEach(function (d) {
varNames.map(function (name) {
series[name].values.push({name: name, label: d[labelVar], value: +d[name]});
});
});
x.domain(data.map(function (d) { return d.year_week; }));
stack(seriesArr);
y.domain([0, d3.max(seriesArr, function (c) {
return d3.max(c.values, function (d) { return d.y0 + d.y; });
})]);
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", ".15em")
.attr("transform", function(d) {
return "rotate(-65)"
});
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");
svg.append("text")
.attr("class", "y label")
.attr("text-anchor", "end")
.attr("x", -240)
.attr("transform", "rotate(-90)")
.attr("y", height-640)
.text("Count");
svg.append("text")
.attr("class", "attribution")
.attr("x", width - 138)
.attr("y", height + 85)
.text("Source: GitHub.com")
svg.append("text")
.attr("class", "x label")
.attr("text-anchor", "end")
.attr("x", width/2)
.attr("y", height + 70)
.text("Date");
var selection = svg.selectAll(".series")
.data(seriesArr)
.enter().append("g")
.attr("class", "series");
selection.append("path")
.attr("class", "streamPath")
.attr("d", function (d) { return area(d.values); })
.style("fill", function (d) { return color(d.name); })
.style("stroke", "grey");
var points = svg.selectAll(".seriesPoints")
.data(seriesArr)
.enter().append("g")
.attr("class", "seriesPoints");
points.selectAll(".point")
.data(function (d) { return d.values; })
.enter().append("circle")
.attr("class", "point")
.attr("cx", function (d) { return x(d.label) + x.rangeBand() / 2; })
.attr("cy", function (d) { return y(d.y0 + d.y); })
.attr("r", "10px")
.style("fill",function (d) { return color(d.name); })
var legend = svg.selectAll(".legend")
.data(varNames.slice().reverse())
.enter().append("g")
.attr("class", "legend")
.attr("transform", function (d, i) { return "translate(-850," + i * 20 + ")"; });
legend.append("rect")
.attr("x", width - 80)
.attr("width", 20)
.attr("height", 20)
.style("fill", color)
.style("stroke", "grey");
legend.append("text")
.attr("x", width - 40)
.attr("y", 10)
.attr("dy", ".5em")
.style("font-size", 12)
.text(function (d) { return toTitleCase(d.replace(/_/g, ' ')); });
function removePopovers () {
$('.popover').each(function() {
$(this).remove();
});
}
function showPopover (d) {
$(this).popover({
title: d.name,
placement: 'auto top',
container: 'body',
trigger: 'manual',
html : true,
content: function() {
return "Quarter: " + d.label +
"<br/>Rounds: " + d3.format(",")(d.value ? d.value: d.y1 - d.y0); }
});
$(this).popover('show')
}
});
</script>
</body>
</html>
year_week issues issue_comments pull_request_comments pull_request_review_comments commits pull_requests
2008-10 0 0 0 0 19 0
2008-11 0 0 0 0 38 0
2008-12 0 0 0 0 115 0
2009-01 0 0 0 0 50 0
2009-02 0 0 0 0 31 0
2009-03 0 0 0 0 37 0
2009-04 26 77 0 0 49 0
2009-05 25 94 0 0 24 0
2009-06 13 65 0 0 19 0
2009-07 8 16 0 0 3 0
2009-08 7 13 0 0 4 0
2009-10 6 17 0 0 3 0
2009-11 5 9 0 0 3 0
2010-01 12 83 0 0 54 0
2010-02 14 23 0 0 21 0
2010-03 7 13 0 0 3 0
2010-04 12 16 0 0 7 0
2010-05 13 12 0 0 1 0
2010-06 14 84 0 0 26 0
2010-08 10 17 0 0 14 0
2010-09 6 10 3 0 7 9
2010-10 6 11 0 0 1 1
2010-11 12 32 13 0 21 7
2010-12 7 25 3 0 15 8
2011-01 9 13 1 0 5 4
2011-02 12 22 8 0 2 3
2011-03 8 44 16 0 23 2
2011-04 7 27 7 0 8 9
2011-05 10 54 30 0 27 8
2011-06 7 36 6 0 11 9
2011-07 10 36 9 1 13 10
2011-08 10 33 8 0 2 7
2011-09 11 38 8 0 3 5
2011-10 14 36 8 0 2 5
2011-11 9 32 23 0 22 7
2011-12 6 42 19 0 13 9
2012-01 19 40 42 4 34 13
2012-02 12 57 14 0 2 6
2012-03 11 42 16 4 1 8
2012-04 9 41 15 0 6 6
2012-05 9 37 20 1 5 10
2012-06 14 63 61 0 5 9
2012-07 12 28 19 29 2 6
2012-08 16 65 31 1 4 8
2012-10 9 56 23 0 4 5
2012-11 7 25 33 0 2 6
2012-12 27 350 150 19 49 17
2013-01 36 293 238 49 148 34
2013-02 18 111 85 34 70 15
2013-03 41 335 199 25 129 41
2013-04 47 306 249 144 285 53
2013-05 83 454 353 101 335 73
2013-06 55 236 225 108 154 32
2013-07 57 371 330 166 237 57
2013-08 56 255 299 83 155 58
2013-09 43 294 410 171 222 64
2013-10 45 221 297 56 150 48
2013-11 49 250 212 52 103 34
2013-12 61 329 348 91 229 68
2014-01 53 368 252 57 163 56
2014-02 50 285 196 35 206 50
2014-03 44 198 200 47 138 38
2014-04 54 341 158 97 195 37
2014-05 86 635 410 107 359 100
2014-06 54 310 110 34 145 41
2014-07 51 382 185 44 163 60
2014-08 87 465 237 54 255 71
2014-09 45 224 140 31 155 55
2014-10 47 227 118 28 125 34
2014-11 65 504 327 83 184 61
2014-12 45 356 194 18 116 28
2015-01 85 559 305 48 213 60
2015-02 73 484 163 33 171 55
2015-03 47 364 318 90 199 53
2015-04 25 191 171 24 88 25
2015-05 41 251 126 26 74 28
2015-06 52 371 133 21 44 21
2015-07 32 189 112 24 30 17
2015-08 51 268 83 18 58 22
2015-09 36 295 128 10 50 12
2015-10 49 345 187 10 111 38
2015-11 66 415 197 32 130 48
2015-12 54 309 114 37 142 41
2016-01 59 328 221 56 293 69
2016-02 91 447 213 45 199 89
2016-03 69 311 290 99 202 60
2016-04 66 367 146 44 130 50
2016-05 48 274 180 186 233 62
2016-06 25 188 158 91 134 31
2009-09 9 19 0 0 0 0
2009-12 11 15 0 0 0 0
2010-07 8 12 0 0 0 0
2012-09 14 38 23 0 0 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment