Skip to content

Commit

Permalink
Merge pull request #77 from cbus-sea-lions-2015/fix-graphs
Browse files Browse the repository at this point in the history
Fix graphs
  • Loading branch information
jannypie committed Apr 24, 2015
2 parents ffc6bc3 + 72ac66b commit 14894ea
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
1 change: 0 additions & 1 deletion app/assets/javascripts/application/routers/users.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ class App.Routers.Users extends App.Router
$('.main-container').html(view.el)
view.render()
if user.attributes.user_github
console.log "User github",user.attributes.user_github
parseHistogram(user.attributes.user_github.eventDates)
displayLanguages(user.attributes.user_github.reposData.allLang, '#js-allLanguages')
displayLanguages(user.attributes.user_github.languages, '#js-recentLanguages')
Expand Down
4 changes: 1 addition & 3 deletions app/assets/javascripts/histogram.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,8 @@ var displayHistogram = function(lineData){

yAxis = d3.svg.axis()
.scale(yRange)
.tickSize(0)
.orient("left")
.tickSubdivide(true)
.ticks(5);
.tickFormat(function (d) { return ''; });

vis.append("svg:g")
.attr("class", "x axis")
Expand Down
22 changes: 18 additions & 4 deletions app/assets/javascripts/pieCharts.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,27 +60,41 @@ var createPieChart = function(dataset, selector){
.duration(2000)
.attrTween("d", tweenPie)
.each('end', function(d){
g.append("svg:text")
.attr("fill","#000")

g.append("svg:text")
.attr("fill","#333")
.style("text-transform","uppercase")
.style("font-size","0.8em")
.style("font-family", "'Montserrat', sans-serif")
.style("margin","10")
.attr("transform", function(d){
d.innerRadius = 25;
d.innerRadius = 10;
d.outerRadius = radius;
return "translate(" + arc.centroid(d) + ")";})
if (dataset.length == 1){
return "translate(" + arc.centroid(d) + ")";
}
else {
return "translate(" + arc.centroid(d) + ")rotate(" + angle(d) + ")";
}
})
.attr("text-anchor", "middle").text(
function(d, i) {
if(dataset[i].value > 0){
return dataset[i].label;
}
}
);


});

function tweenPie(b) {
var i = d3.interpolate({startAngle: 1.1*Math.PI, endAngle: 1.1*Math.PI}, b);
return function(t) { return arc(i(t)); };
}

function angle(d) {
var a = (d.startAngle + d.endAngle) * 90 / Math.PI - 90;
return a > 90 ? a - 180 : a;
}
}

0 comments on commit 14894ea

Please sign in to comment.