Skip to content

Instantly share code, notes, and snippets.

@audreyfeldroy
Last active December 20, 2015 16:18
Show Gist options
  • Save audreyfeldroy/6160025 to your computer and use it in GitHub Desktop.
Save audreyfeldroy/6160025 to your computer and use it in GitHub Desktop.
Thicker repo sparkline producing a harsher effect.
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Thicker repo sparkline producing a harsher effect." />
<script src="http://d3js.org/d3.v3.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
<svg class="sparkline" width="104" height="30"></svg>
</body>
</html>
text {
font: 10px sans-serif;
}
svg {
background-color: #efefef;
}
var data;
function adjust_commits(d) {
if (d.total >= 30) {
return 30;
} else {
return d.total;
}
}
d3.json("http://jsbin.com/ipamut", function(json) {
data = json;
var week = d3.select(".sparkline").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", 2)
.attr("height", adjust_commits);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment