-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Converted the 'Dashboard' tab of the ViewRepoImpact view to use a sin…
…gle SVG div.
- Loading branch information
Showing
2 changed files
with
37 additions
and
32 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,57 @@ | ||
/// <reference path="jquery-1.4.4-vsdoc.js" /> | ||
|
||
function buildGraph(div, column) { | ||
function readValues(column, normalize) { | ||
normalize = normalize || function (a) { return a; }; | ||
|
||
var headers = $("#stats-table thead th").get(); | ||
var getIndex = function (headerText) { | ||
return headers.indexOf($.map(headers, function (h) { if ($(h).text() === headerText) { return h; } })[0]); | ||
}; | ||
|
||
var rows = $("#stats-table tbody tr"); | ||
var getValues = function (headerText, normalize) { | ||
normalize = normalize || function (a) { return a; }; | ||
var colIndex = getIndex(headerText); | ||
return $.map(rows, function (item) { return normalize($($(item).find("td")[colIndex]).text()); }); | ||
}; | ||
|
||
var names = getValues("Author"); | ||
var values = getValues(column, function (a) { return +a; }); | ||
return getValues(column, normalize); | ||
} | ||
|
||
function buildGraph(div) { | ||
|
||
var r = Raphael(div); | ||
r.g.text(250, 20, column).attr({ "font-size": 20 }); | ||
var pie = r.g.piechart(110, 110, 100, values, { legend: names, legendpos: "east" }) | ||
pie.hover(function () { | ||
var labels = readValues("Author"); | ||
var commits = readValues("Commits", function (a) { return +a; }); | ||
var insertions = readValues("Insertions", function (a) { return +a; }); | ||
var deletions = readValues("Deletions", function (a) { return +a; }); | ||
var impact = readValues("Impact", function (a) { return +a; }); | ||
|
||
var hIn = function () { | ||
this.sector.stop(); | ||
this.sector.scale(1.1, 1.1, this.cx, this.cy); | ||
if (this.label) { | ||
this.label[0].stop(); | ||
this.label[0].scale(1.5); | ||
this.label[1].attr({ "font-weight": 800 }); | ||
} | ||
}, function () { | ||
}; | ||
|
||
var hOut = function () { | ||
this.sector.animate({ scale: [1, 1, this.cx, this.cy] }, 500, "bounce"); | ||
if (this.label) { | ||
this.label[0].animate({ scale: 1 }, 500, "bounce"); | ||
this.label[1].attr({ "font-weight": 400 }); | ||
} | ||
}); | ||
}; | ||
|
||
var r = Raphael(div, 1000, 220); | ||
r.g.text(250, 20, "Commits").attr({ "font-size": 20 }); | ||
r.g.text(750, 20, "Impact").attr({ "font-size": 20 }); | ||
r.g.piechart(110, 110, 100, commits, { legend: labels, legendpos: "east" }).hover(hIn, hOut); | ||
r.g.piechart(610, 110, 100, impact, { legend: labels, legendpos: "east" }).hover(hIn, hOut); | ||
} | ||
|
||
$(function () { | ||
impact("weekly-graph", data, { heightfunc: Math.sqrt }); | ||
|
||
buildGraph("users-dashboard"); | ||
}); |
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