summaryrefslogtreecommitdiff
path: root/assets/js/src/analytic.js
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-07-05 21:22:31 -0400
committerFrederic Guillot <fred@kanboard.net>2015-07-05 21:22:31 -0400
commit663a1c20e6ba0fbf65afcb43f0f48d34f21dcb53 (patch)
tree86b86c9c83770456242fb65779aac68dc497fb54 /assets/js/src/analytic.js
parentbb8b4c0e36afc05ff5b0cb3ac6465351a696b001 (diff)
Add new analytic page: Average time spent into each column
Diffstat (limited to 'assets/js/src/analytic.js')
-rw-r--r--assets/js/src/analytic.js99
1 files changed, 99 insertions, 0 deletions
diff --git a/assets/js/src/analytic.js b/assets/js/src/analytic.js
index bec4d76e..0375f0be 100644
--- a/assets/js/src/analytic.js
+++ b/assets/js/src/analytic.js
@@ -165,6 +165,99 @@
});
}
+ // Draw chart for average time spent into each column
+ function drawAvgTimeColumn()
+ {
+ var metrics = $("#chart").data("metrics");
+ var plots = [$("#chart").data("label")];
+ var categories = [];
+
+ for (var column_id in metrics) {
+ plots.push(metrics[column_id].average);
+ categories.push(metrics[column_id].title);
+ }
+
+ c3.generate({
+ data: {
+ columns: [plots],
+ type: 'bar'
+ },
+ bar: {
+ width: {
+ ratio: 0.5
+ }
+ },
+ axis: {
+ x: {
+ type: 'category',
+ categories: categories
+ },
+ y: {
+ tick: {
+ format: formatDuration
+ }
+ }
+ },
+ legend: {
+ show: false
+ }
+ });
+ }
+
+ // Draw chart for average time spent into each column
+ function drawTaskTimeColumn()
+ {
+ var metrics = $("#chart").data("metrics");
+ var plots = [$("#chart").data("label")];
+ var categories = [];
+
+ for (var i = 0; i < metrics.length; i++) {
+ plots.push(metrics[i].time_spent);
+ categories.push(metrics[i].title);
+ }
+
+ c3.generate({
+ data: {
+ columns: [plots],
+ type: 'bar'
+ },
+ bar: {
+ width: {
+ ratio: 0.5
+ }
+ },
+ axis: {
+ x: {
+ type: 'category',
+ categories: categories
+ },
+ y: {
+ tick: {
+ format: formatDuration
+ }
+ }
+ },
+ legend: {
+ show: false
+ }
+ });
+ }
+
+ function formatDuration(d)
+ {
+ if (d >= 86400) {
+ return Math.round(d/86400) + "d";
+ }
+ else if (d >= 3600) {
+ return Math.round(d/3600) + "h";
+ }
+ else if (d >= 60) {
+ return Math.round(d/60) + "m";
+ }
+
+ return d + "s";
+ }
+
jQuery(document).ready(function() {
if (Kanboard.Exists("analytic-task-repartition")) {
@@ -182,6 +275,12 @@
else if (Kanboard.Exists("budget-chart")) {
drawBudget();
}
+ else if (Kanboard.Exists("analytic-avg-time-column")) {
+ drawAvgTimeColumn();
+ }
+ else if (Kanboard.Exists("analytic-task-time-column")) {
+ drawTaskTimeColumn();
+ }
});
})();