Created
July 14, 2013 20:37
-
-
Save zombiecalypse/5995898 to your computer and use it in GitHub Desktop.
D3 visualisation of participation in a github project
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
Array::unique = -> | |
output = {} | |
output[@[key]] = @[key] for key in [0...@length] | |
value for key, value of output | |
user = "ese-unibe-ch" | |
repo = "ese2012-team5" | |
url = "https://api.github.com/repos/#{user}/#{repo}/commits?per_page=1000" | |
$(document).ready -> | |
$.getJSON(url).done (info) -> | |
all_emails = [c.commit.committer.email for c in info][0].unique() | |
t_format = d3.time.format("%Y-%m-%dT%H:%M:%SZ") | |
all_times = [+t_format.parse(c.commit.committer.date) for c in info][0] | |
scale_email = d3.scale.category10() | |
scale_x = d3.scale.linear() | |
.domain([d3.min(all_times), d3.max(all_times)]) | |
.range([30, 470]) | |
scale_y = d3.scale.ordinal() | |
.domain(all_emails) | |
.rangePoints([150, 250]) | |
chart = d3.select("body") | |
.append("svg") | |
.attr("width", 500) | |
.attr("height", 500) | |
chart.selectAll("circle").data(info).enter() | |
.append("circle") | |
.attr("fill", (d) -> | |
scale_email(d.commit.committer.email)) | |
.attr("cx", (d) -> scale_x(+t_format.parse(d.commit.committer.date))) | |
.attr("cy", (d) -> scale_y(d.commit.committer.email)) | |
.attr("r", 5) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment