summaryrefslogtreecommitdiff
path: root/assets/js/components
diff options
context:
space:
mode:
authorFrederic Guillot <fred@kanboard.net>2016-09-03 21:20:54 -0400
committerFrederic Guillot <fred@kanboard.net>2016-09-03 21:20:54 -0400
commitdaa076eea7185a3b67dbfed7b34e42f3049026df (patch)
tree88ee41cdffc98bcae415dcd2e88787f249a787db /assets/js/components
parentef8ddb59c94e24383531e52371b70b595dff8e24 (diff)
Convert time comparison chart to Vue.js component
Diffstat (limited to 'assets/js/components')
-rw-r--r--assets/js/components/chart-project-time-comparison.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/assets/js/components/chart-project-time-comparison.js b/assets/js/components/chart-project-time-comparison.js
new file mode 100644
index 00000000..6fbdb919
--- /dev/null
+++ b/assets/js/components/chart-project-time-comparison.js
@@ -0,0 +1,36 @@
+Vue.component('chart-project-time-comparison', {
+ props: ['metrics', 'labelSpent', 'labelEstimated', 'labelClosed', 'labelOpen'],
+ template: '<div id="chart"></div>',
+ ready: function () {
+ var spent = [this.labelSpent];
+ var estimated = [this.labelEstimated];
+ var categories = [];
+
+ for (var status in this.metrics) {
+ spent.push(this.metrics[status].time_spent);
+ estimated.push(this.metrics[status].time_estimated);
+ categories.push(status === 'open' ? this.labelOpen : this.labelClosed);
+ }
+
+ c3.generate({
+ data: {
+ columns: [spent, estimated],
+ type: 'bar'
+ },
+ bar: {
+ width: {
+ ratio: 0.2
+ }
+ },
+ axis: {
+ x: {
+ type: 'category',
+ categories: categories
+ }
+ },
+ legend: {
+ show: true
+ }
+ });
+ }
+});