Convert time comparison chart to Vue.js component

This commit is contained in:
Frederic Guillot
2016-09-03 21:20:54 -04:00
parent ef8ddb59c9
commit daa076eea7
7 changed files with 53 additions and 64 deletions

View File

@@ -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
}
});
}
});