summaryrefslogtreecommitdiff
path: root/assets/js/components/chart-project-avg-time-column.js
blob: 74fe31dec5c1bdac5169a9232dbbc0e8ac82a7d3 (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
KB.component('chart-project-avg-time-column', function (containerElement, options) {

    this.render = function () {
        var metrics = options.metrics;
        var plots = [options.label];
        var categories = [];

        for (var column_id in metrics) {
            plots.push(metrics[column_id].average);
            categories.push(metrics[column_id].title);
        }

        KB.el(containerElement).add(KB.el('div').attr('id', 'chart').build());

        c3.generate({
            data: {
                columns: [plots],
                type: 'bar'
            },
            bar: {
                width: {
                    ratio: 0.5
                }
            },
            axis: {
                x: {
                    type: 'category',
                    categories: categories
                },
                y: {
                    tick: {
                        format: KB.utils.formatDuration
                    }
                }
            },
            legend: {
                show: false
            }
        });
    };
});