summaryrefslogtreecommitdiff
path: root/assets/js/src/CompareHoursColumnChart.js
blob: d40809d273d78f669f3c8a400a58f2f1db388520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
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
        }
    });
};