From 583e6bf064bbbdd0b031ea429fb1de949ddf64a7 Mon Sep 17 00:00:00 2001 From: Matthew Cillo Date: Mon, 7 Dec 2015 22:40:55 -0500 Subject: added working template of compare hours --- assets/js/src/CompareHoursColumnChart.js | 43 ++++++++++++++++++++++++++++++++ assets/js/src/Router.js | 1 + 2 files changed, 44 insertions(+) create mode 100644 assets/js/src/CompareHoursColumnChart.js (limited to 'assets') diff --git a/assets/js/src/CompareHoursColumnChart.js b/assets/js/src/CompareHoursColumnChart.js new file mode 100644 index 00000000..fca67689 --- /dev/null +++ b/assets/js/src/CompareHoursColumnChart.js @@ -0,0 +1,43 @@ +function CompareHoursColumnChart(app) { + this.app = app; +} + +CompareHoursColumnChart.prototype.execute = function() { + var metrics = $("#chart").data("metrics"); + var spent = [$("#chart").data("label-spent")]; + var estimated = [$("#chart").data("label-estimated")]; + var categories = []; + + for (var status in metrics) { + spent.push(parseInt(metrics[status].time_spent)); + estimated.push(parseInt(metrics[status].time_estimated)); + categories.push(status); + } + + console.log(spent); + c3.generate({ + data: { + columns: [spent, estimated], + type: 'bar' + }, + bar: { + width: { + ratio: 0.2 + } + }, + axis: { + x: { + type: 'category', + categories: categories + }, + y: { + tick: { + format: this.app.formatDuration + } + } + }, + legend: { + show: true + } + }); +}; diff --git a/assets/js/src/Router.js b/assets/js/src/Router.js index 0c96262c..ab23c0fd 100644 --- a/assets/js/src/Router.js +++ b/assets/js/src/Router.js @@ -30,6 +30,7 @@ jQuery(document).ready(function() { router.addRoute('analytic-avg-time-column', AvgTimeColumnChart); router.addRoute('analytic-task-time-column', TaskTimeColumnChart); router.addRoute('analytic-lead-cycle-time', LeadCycleTimeChart); + router.addRoute('analytic-compare-hours', CompareHoursColumnChart); router.addRoute('gantt-chart', Gantt); router.dispatch(app); app.listen(); -- cgit v1.2.3 From c72e13a976a64feee992b77b1d676bf584e44c47 Mon Sep 17 00:00:00 2001 From: Matthew Cillo Date: Fri, 11 Dec 2015 21:16:00 -0500 Subject: removed debug line and added title --- app/Controller/Analytic.php | 1 + assets/js/src/CompareHoursColumnChart.js | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) (limited to 'assets') diff --git a/app/Controller/Analytic.php b/app/Controller/Analytic.php index 603ace01..62f55f8d 100644 --- a/app/Controller/Analytic.php +++ b/app/Controller/Analytic.php @@ -188,6 +188,7 @@ class Analytic extends Base 'project' => $project, 'paginator' => $paginator, 'metrics' => $stats, + 'title' => t('Compare hours for "%s"', $project['name']), ))); } } diff --git a/assets/js/src/CompareHoursColumnChart.js b/assets/js/src/CompareHoursColumnChart.js index fca67689..d40809d2 100644 --- a/assets/js/src/CompareHoursColumnChart.js +++ b/assets/js/src/CompareHoursColumnChart.js @@ -14,7 +14,6 @@ CompareHoursColumnChart.prototype.execute = function() { categories.push(status); } - console.log(spent); c3.generate({ data: { columns: [spent, estimated], -- cgit v1.2.3