diff options
Diffstat (limited to 'assets/js')
-rw-r--r-- | assets/js/analytic.js | 54 | ||||
-rw-r--r-- | assets/js/app.js | 54 |
2 files changed, 102 insertions, 6 deletions
diff --git a/assets/js/analytic.js b/assets/js/analytic.js index 32d3037a..22fb672e 100644 --- a/assets/js/analytic.js +++ b/assets/js/analytic.js @@ -4,15 +4,18 @@ Kanboard.Analytic = (function() { return { Init: function() { - if (Kanboard.Exists("analytic-repartition")) { - Kanboard.Analytic.Repartition.Init(); + if (Kanboard.Exists("analytic-task-repartition")) { + Kanboard.Analytic.TaskRepartition.Init(); + } + else if (Kanboard.Exists("analytic-user-repartition")) { + Kanboard.Analytic.UserRepartition.Init(); } } }; })(); -Kanboard.Analytic.Repartition = (function() { +Kanboard.Analytic.TaskRepartition = (function() { function fetchData() { @@ -56,3 +59,48 @@ Kanboard.Analytic.Repartition = (function() { }; })(); + +Kanboard.Analytic.UserRepartition = (function() { + + function fetchData() + { + jQuery.getJSON($("#chart").attr("data-url"), function(data) { + drawGraph(data.metrics, data.labels); + }); + } + + function drawGraph(metrics, labels) + { + var series = prepareSeries(metrics, labels); + + var svg = dimple.newSvg("#chart", 700, 350); + + var chart = new dimple.chart(svg, series); + chart.addMeasureAxis("p", labels["nb_tasks"]); + var ring = chart.addSeries(labels["user"], dimple.plot.pie); + ring.innerRadius = "50%"; + chart.addLegend(0, 0, 100, 100, "left"); + chart.draw(); + } + + function prepareSeries(metrics, labels) + { + var series = []; + + for (var i = 0; i < metrics.length; i++) { + + var serie = {}; + serie[labels["nb_tasks"]] = metrics[i]["nb_tasks"]; + serie[labels["user"]] = metrics[i]["user"]; + + series.push(serie); + } + + return series; + } + + return { + Init: fetchData + }; + +})(); diff --git a/assets/js/app.js b/assets/js/app.js index 55bc4039..ed017b0b 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -273,15 +273,18 @@ Kanboard.Analytic = (function() { return { Init: function() { - if (Kanboard.Exists("analytic-repartition")) { - Kanboard.Analytic.Repartition.Init(); + if (Kanboard.Exists("analytic-task-repartition")) { + Kanboard.Analytic.TaskRepartition.Init(); + } + else if (Kanboard.Exists("analytic-user-repartition")) { + Kanboard.Analytic.UserRepartition.Init(); } } }; })(); -Kanboard.Analytic.Repartition = (function() { +Kanboard.Analytic.TaskRepartition = (function() { function fetchData() { @@ -325,6 +328,51 @@ Kanboard.Analytic.Repartition = (function() { }; })(); + +Kanboard.Analytic.UserRepartition = (function() { + + function fetchData() + { + jQuery.getJSON($("#chart").attr("data-url"), function(data) { + drawGraph(data.metrics, data.labels); + }); + } + + function drawGraph(metrics, labels) + { + var series = prepareSeries(metrics, labels); + + var svg = dimple.newSvg("#chart", 700, 350); + + var chart = new dimple.chart(svg, series); + chart.addMeasureAxis("p", labels["nb_tasks"]); + var ring = chart.addSeries(labels["user"], dimple.plot.pie); + ring.innerRadius = "50%"; + chart.addLegend(0, 0, 100, 100, "left"); + chart.draw(); + } + + function prepareSeries(metrics, labels) + { + var series = []; + + for (var i = 0; i < metrics.length; i++) { + + var serie = {}; + serie[labels["nb_tasks"]] = metrics[i]["nb_tasks"]; + serie[labels["user"]] = metrics[i]["user"]; + + series.push(serie); + } + + return series; + } + + return { + Init: fetchData + }; + +})(); // Initialization $(function() { |