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

Kanboard.TaskTimeColumnChart.prototype.execute = function() {
    if (this.app.hasId("analytic-task-time-column")) {
        this.show();
    }
};

Kanboard.TaskTimeColumnChart.prototype.show = function() {
    var chart = $("#chart");
    var metrics = chart.data("metrics");
    var plots = [chart.data("label")];
    var categories = [];

    for (var i = 0; i < metrics.length; i++) {
        plots.push(metrics[i].time_spent);
        categories.push(metrics[i].title);
    }

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