From 33dbe4e39a9e68433acd2bcf2d4a61a84c098eed Mon Sep 17 00:00:00 2001 From: John Gietzen Date: Sat, 17 Sep 2011 01:35:45 -0500 Subject: [PATCH] Converted the 'Dashboard' tab of the ViewRepoImpact view to use a single SVG div. --- WebGitNet/Scripts/repo-impact.js | 40 +++++++++++++++----- WebGitNet/Views/Browse/ViewRepoImpact.cshtml | 29 ++++---------- 2 files changed, 37 insertions(+), 32 deletions(-) diff --git a/WebGitNet/Scripts/repo-impact.js b/WebGitNet/Scripts/repo-impact.js index 65ad0a6..97324e6 100644 --- a/WebGitNet/Scripts/repo-impact.js +++ b/WebGitNet/Scripts/repo-impact.js @@ -1,6 +1,8 @@ /// -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]); @@ -8,18 +10,22 @@ function buildGraph(div, column) { 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) { @@ -27,11 +33,25 @@ function buildGraph(div, column) { 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"); +}); \ No newline at end of file diff --git a/WebGitNet/Views/Browse/ViewRepoImpact.cshtml b/WebGitNet/Views/Browse/ViewRepoImpact.cshtml index fa9b1aa..dcfd9c9 100644 --- a/WebGitNet/Views/Browse/ViewRepoImpact.cshtml +++ b/WebGitNet/Views/Browse/ViewRepoImpact.cshtml @@ -54,46 +54,30 @@ }
-
-
-
-
-
+
@@ -119,4 +103,5 @@
-
\ No newline at end of file +
+