GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( e8fdb9...e39adc )
by
unknown
11:29
created

report-chart.js ➔ generatePolarChart   A

Complexity

Conditions 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
c 0
b 0
f 0
dl 0
loc 6
rs 10
1
function generateLineChart(labels, values, ctx) {
2
    data = {
0 ignored issues
show
Bug introduced by
The variable data seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.data.
Loading history...
3
        labels : labels,
4
        datasets : [
5
            {
6
                fillColor : "rgba(26,187,156,0.5)",
7
                strokeColor : "rgba(55,163,126,1)",
8
                pointColor : "rgba(55,163,126,1)",
9
                pointStrokeColor : "#fff",
10
                pointHighlightFill : "#fff",
11
                pointHighlightStroke : "rgba(55,163,126,1)",
12
                data : values
13
            }
14
        ]
15
    }
16
    window.myLine = new Chart(ctx).Line(data, {
0 ignored issues
show
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
17
        responsive: true,
18
        maintainAspectRatio: false
19
    });
20
}
21
function generateBarChart(labels, values, ctx) {
22
    data = {
0 ignored issues
show
Bug introduced by
The variable data seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.data.
Loading history...
23
        labels : labels,
24
        datasets : [
25
            {
26
                fillColor : "rgba(220,220,220,0.5)",
27
                strokeColor : "rgba(220,220,220,0.8)",
28
                highlightFill: "rgba(220,220,220,0.75)",
29
                highlightStroke: "rgba(220,220,220,1)",
30
                data : values
31
            }
32
        ]
33
    }
34
    window.myBar = new Chart(ctx).Bar(data, {
0 ignored issues
show
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
35
        responsive: true,
36
        maintainAspectRatio: false
37
    });
38
}
39
function generateRadarChart(labels, values, ctx) {
40
    data = {
0 ignored issues
show
Bug introduced by
The variable data seems to be never declared. Assigning variables without defining them first makes them global. If this was intended, consider making it explicit like using window.data.
Loading history...
41
        labels: labels,
42
        datasets: [
43
            {
44
                fillColor: "rgba(26,187,156,0.5)",
45
                strokeColor: "#37a37e",
46
                pointColor: "rgba(220,220,220,1)",
47
                pointStrokeColor: "#fff",
48
                pointHighlightFill: "#fff",
49
                pointHighlightStroke: "rgba(220,220,220,1)",
50
                data: values
51
            }
52
        ]
53
    }
54
    $("#canvas").width(600).height("auto");
55
    window.myBar = new Chart(ctx).Radar(data, {
0 ignored issues
show
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
56
        responsive: true,
57
        maintainAspectRatio: false
58
    });
59
}
60
function generatePolarChart(labels, values, ctx) {
61
    window.myBar = new Chart(ctx).PolarArea(generateRadialData(labels, values), {
0 ignored issues
show
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
62
        responsive: true,
63
        maintainAspectRatio: false
64
    });
65
}
66
function generatePieChart(labels, values, ctx) {
67
    window.myBar = new Chart(ctx).Pie(generateRadialData(labels, values), {
0 ignored issues
show
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
68
        responsive: true,
69
        maintainAspectRatio: false
70
    });
71
}
72
function generateDoughnutChart(labels, values, ctx) {
73
    window.myBar = new Chart(ctx).Doughnut(generateRadialData(labels, values), {
0 ignored issues
show
Bug introduced by
The variable Chart seems to be never declared. If this is a global, consider adding a /** global: Chart */ comment.

This checks looks for references to variables that have not been declared. This is most likey a typographical error or a variable has been renamed.

To learn more about declaring variables in Javascript, see the MDN.

Loading history...
74
        responsive: true,
75
        maintainAspectRatio: false
76
    });
77
}
78
function generateRadialData(labels, values) {
79
    var colors = ["#1abb9c", "#F7464A", "#46BFBD", "#FDB45C", "#949FB1", "#4D5360", "#bdbdbd", "#AA66CC", "33B5E5"];
80
    var highlights = ["#37a37e", "#FF5A5E", "#5AD3D1", "#FFC870", "#A8B3C5", "#616774", "#acacac", "#9933CC", "0099CC"];
81
    var data = [];
82
    $.each(values, function(i){
83
        var fragment = {
84
            value: parseInt(this),
85
            color: colors[i%9],
86
            highlight: highlights[i%9],
87
            label: labels[i]
88
        };
89
        data.push(fragment);
90
    });
91
    return data;
92
}
93
94
function initChart(self){
95
    var chartType = self.attr("data-type");
96
    var reportCode = self.attr("id");
97
    var labels = self.attr("data-labels").split(";");
98
    var values = self.attr("data-values").split(";");
99
100
    var ctx = document.getElementById(reportCode).getContext("2d");
101
    switch(chartType) {
102
        case "line": generateLineChart(labels, values, ctx); break;
103
        case "bar": generateBarChart(labels, values, ctx); break;
104
        case "radar": generateRadarChart(labels, values, ctx); break;
105
        case "polar": generatePolarChart(labels, values, ctx); break;
106
        case "pie": generatePieChart(labels, values, ctx); break;
107
        case "doughnut": generateDoughnutChart(labels, values, ctx); break;
108
    }
109
}
110
111
window.addEventListener("load",function(){
112
    $.each($("canvas"), function(){
113
        initChart($(this));
114
    });
115
});
116