summaryrefslogtreecommitdiff
path: root/assets/js/components/chart-project-lead-cycle-time.js
blob: a81937ff669eb1cba95cce65bf7252c476c5e60c (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
43
44
45
46
47
KB.component('chart-project-lead-cycle-time', function (containerElement, options) {

    this.render = function () {
        var metrics = options.metrics;
        var cycle = [options.labelCycle];
        var lead = [options.labelLead];
        var categories = [];

        var types = {};
        types[options.labelCycle] = 'area';
        types[options.labelLead] = 'area-spline';

        var colors = {};
        colors[options.labelLead] = '#afb42b';
        colors[options.labelCycle] = '#4e342e';

        for (var i = 0; i < metrics.length; i++) {
            cycle.push(parseInt(metrics[i].avg_cycle_time));
            lead.push(parseInt(metrics[i].avg_lead_time));
            categories.push(metrics[i].day);
        }

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

        c3.generate({
            data: {
                columns: [
                    lead,
                    cycle
                ],
                types: types,
                colors: colors
            },
            axis: {
                x: {
                    type: 'category',
                    categories: categories
                },
                y: {
                    tick: {
                        format: KB.utils.formatDuration
                    }
                }
            }
        });
    };
});