summaryrefslogtreecommitdiff
path: root/assets/js/src/LeadCycleTimeChart.js
blob: 9ba4a22280bcd1de39bd0cab220e962c5122a638 (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
function LeadCycleTimeChart(app) {
    this.app = app;
}

LeadCycleTimeChart.prototype.execute = function() {
    var metrics = $("#chart").data("metrics");
    var cycle = [$("#chart").data("label-cycle")];
    var lead = [$("#chart").data("label-lead")];
    var categories = [];

    var types = {};
    types[$("#chart").data("label-cycle")] = 'area';
    types[$("#chart").data("label-lead")] = 'area-spline';

    var colors = {};
    colors[$("#chart").data("label-lead")] = '#afb42b';
    colors[$("#chart").data("label-cycle")] = '#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);
    }

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