summaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2015-12-14 21:54:40 -0500
committerFrederic Guillot <fred@kanboard.net>2015-12-14 21:54:40 -0500
commit3897b1de596475e9556383b03cc41aa1df3b50c1 (patch)
treeb1868795a16d38442824830892e586a7af6aec7e /assets/js
parent268a83ffbdf196139cc07c62e44dc3cf7fbb297d (diff)
parentb2b75a4a6e58ffda180e148fe87f996a24fa6973 (diff)
Merge pull-request #1528
Diffstat (limited to 'assets/js')
-rw-r--r--assets/js/src/CompareHoursColumnChart.js42
-rw-r--r--assets/js/src/Router.js1
2 files changed, 43 insertions, 0 deletions
diff --git a/assets/js/src/CompareHoursColumnChart.js b/assets/js/src/CompareHoursColumnChart.js
new file mode 100644
index 00000000..d40809d2
--- /dev/null
+++ b/assets/js/src/CompareHoursColumnChart.js
@@ -0,0 +1,42 @@
+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);
+ }
+
+ 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();