Skip to content

Instantly share code, notes, and snippets.

@georules
Created August 3, 2013 12:29
Show Gist options
  • Select an option

  • Save georules/6146284 to your computer and use it in GitHub Desktop.

Select an option

Save georules/6146284 to your computer and use it in GitHub Desktop.
GitHub Repo Sparkline 2
[
{
"days": [
0,
0,
7,
3,
3,
9,
0
],
"total": 22,
"week": 1344124800
},
{
"days": [
0,
16,
11,
6,
4,
4,
3
],
"total": 44,
"week": 1344729600
},
{
"days": [
0,
0,
1,
13,
2,
0,
0
],
"total": 16,
"week": 1345334400
},
{
"days": [
0,
0,
2,
0,
1,
0,
0
],
"total": 3,
"week": 1345939200
},
{
"days": [
0,
0,
1,
1,
0,
0,
0
],
"total": 2,
"week": 1346544000
},
{
"days": [
1,
0,
0,
7,
1,
8,
0
],
"total": 17,
"week": 1347148800
},
{
"days": [
0,
2,
1,
14,
1,
14,
0
],
"total": 32,
"week": 1347753600
},
{
"days": [
0,
3,
11,
5,
1,
0,
0
],
"total": 20,
"week": 1348358400
},
{
"days": [
6,
4,
4,
11,
3,
2,
0
],
"total": 30,
"week": 1348963200
},
{
"days": [
0,
5,
7,
1,
3,
2,
0
],
"total": 18,
"week": 1349568000
},
{
"days": [
0,
0,
1,
7,
9,
8,
0
],
"total": 25,
"week": 1350172800
},
{
"days": [
0,
3,
0,
0,
5,
2,
0
],
"total": 10,
"week": 1350777600
},
{
"days": [
0,
2,
3,
0,
0,
1,
0
],
"total": 6,
"week": 1351382400
},
{
"days": [
0,
3,
1,
0,
0,
18,
0
],
"total": 22,
"week": 1351987200
},
{
"days": [
0,
6,
4,
6,
1,
7,
0
],
"total": 24,
"week": 1352592000
},
{
"days": [
0,
5,
2,
1,
1,
2,
1
],
"total": 12,
"week": 1353196800
},
{
"days": [
1,
1,
1,
4,
7,
3,
2
],
"total": 19,
"week": 1353801600
},
{
"days": [
0,
2,
6,
6,
1,
1,
0
],
"total": 16,
"week": 1354406400
},
{
"days": [
3,
7,
1,
3,
1,
0,
0
],
"total": 15,
"week": 1355011200
},
{
"days": [
0,
8,
8,
6,
3,
1,
0
],
"total": 26,
"week": 1355616000
},
{
"days": [
0,
0,
0,
0,
0,
0,
0
],
"total": 0,
"week": 1356220800
},
{
"days": [
0,
0,
0,
0,
1,
0,
0
],
"total": 1,
"week": 1356825600
},
{
"days": [
0,
3,
0,
0,
6,
2,
0
],
"total": 11,
"week": 1357430400
},
{
"days": [
0,
3,
7,
15,
8,
7,
0
],
"total": 40,
"week": 1358035200
},
{
"days": [
2,
1,
1,
0,
0,
0,
1
],
"total": 5,
"week": 1358640000
},
{
"days": [
4,
0,
0,
1,
0,
0,
0
],
"total": 5,
"week": 1359244800
},
{
"days": [
1,
0,
0,
0,
2,
0,
0
],
"total": 3,
"week": 1359849600
},
{
"days": [
0,
0,
0,
0,
0,
1,
0
],
"total": 1,
"week": 1360454400
},
{
"days": [
0,
0,
1,
0,
0,
0,
0
],
"total": 1,
"week": 1361059200
},
{
"days": [
0,
0,
0,
1,
1,
0,
0
],
"total": 2,
"week": 1361664000
},
{
"days": [
0,
0,
0,
0,
0,
0,
0
],
"total": 0,
"week": 1362268800
},
{
"days": [
0,
0,
0,
0,
0,
1,
0
],
"total": 1,
"week": 1362873600
},
{
"days": [
0,
0,
10,
2,
0,
0,
2
],
"total": 14,
"week": 1363478400
},
{
"days": [
0,
0,
12,
5,
2,
3,
0
],
"total": 22,
"week": 1364083200
},
{
"days": [
0,
0,
0,
2,
5,
8,
1
],
"total": 16,
"week": 1364688000
},
{
"days": [
2,
12,
6,
2,
5,
2,
0
],
"total": 29,
"week": 1365292800
},
{
"days": [
0,
4,
1,
5,
4,
3,
1
],
"total": 18,
"week": 1365897600
},
{
"days": [
0,
1,
13,
8,
3,
6,
0
],
"total": 31,
"week": 1366502400
},
{
"days": [
1,
4,
18,
2,
9,
10,
1
],
"total": 45,
"week": 1367107200
},
{
"days": [
0,
6,
4,
9,
7,
2,
0
],
"total": 28,
"week": 1367712000
},
{
"days": [
1,
15,
19,
22,
25,
26,
45
],
"total": 153,
"week": 1368316800
},
{
"days": [
18,
1,
13,
6,
4,
10,
0
],
"total": 52,
"week": 1368921600
},
{
"days": [
3,
0,
2,
9,
4,
4,
0
],
"total": 22,
"week": 1369526400
},
{
"days": [
2,
1,
2,
5,
18,
18,
17
],
"total": 63,
"week": 1370131200
},
{
"days": [
16,
8,
8,
3,
2,
7,
0
],
"total": 44,
"week": 1370736000
},
{
"days": [
0,
9,
12,
23,
3,
0,
0
],
"total": 47,
"week": 1371340800
},
{
"days": [
0,
4,
18,
23,
20,
11,
6
],
"total": 82,
"week": 1371945600
},
{
"days": [
1,
3,
4,
2,
1,
3,
0
],
"total": 14,
"week": 1372550400
},
{
"days": [
1,
0,
13,
10,
16,
4,
0
],
"total": 44,
"week": 1373155200
},
{
"days": [
3,
5,
9,
3,
1,
3,
2
],
"total": 26,
"week": 1373760000
},
{
"days": [
0,
6,
0,
1,
6,
12,
4
],
"total": 29,
"week": 1374364800
},
{
"days": [
0,
0,
0,
4,
0,
0,
0
],
"total": 4,
"week": 1374969600
}
]
{"description":"GitHub Repo Sparkline 2","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"README.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"index.html":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"commit_activity.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"thumbnail.png":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"thumbnail":"http://i.imgur.com/eKiPlSg.png"}
var data;
function adjust_commits(d) {
if (d.total >= 30) {
return 30;
} else {
return d.total;
}
}
json = tributary.commit_activity;
data = json;
var week = d3.select("svg").selectAll(".week")
.data(json)
.enter().append("g")
.attr("class", "week");
week.append("rect")
.attr("x", function(d) { return data.indexOf(d) * 2; })
.attr("y", function(d) { return 30 - adjust_commits(d); })
.attr("width", 1)
.attr("height", adjust_commits);
text {
font: 10px sans-serif;
}
svg {
background-color: #efefef;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment