Last active
December 20, 2015 16:18
-
-
Save audreyfeldroy/6160025 to your computer and use it in GitHub Desktop.
Thicker repo sparkline producing a harsher effect.
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> | |
<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> |
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
text { | |
font: 10px sans-serif; | |
} | |
svg { | |
background-color: #efefef; | |
} |
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
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