Passed
Push — master ( c84e5c...0e0008 )
by philippe
04:14
created

doc/phpmetrics/js/graph-maintainability.js   A

Complexity

Total Complexity 13
Complexity/F 1.18

Size

Lines of Code 72
Function Count 11

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 13
eloc 49
dl 0
loc 72
rs 10
c 1
b 0
f 0
cc 0
nc 1
mnd 2
bc 14
fnc 11
bpm 1.2727
cpm 1.1818
noi 5
1
function chartMaintainability() {
2
3
    var diameter = document.getElementById('svg-maintainability').offsetWidth;
4
5
    var json = {
6
        name: 'chart',
7
        children: classes
0 ignored issues
show
Bug introduced by
The variable classes seems to be never declared. If this is a global, consider adding a /** global: classes */ 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...
8
    };
9
10
    var svg = d3.select('#svg-maintainability').append('svg')
0 ignored issues
show
Bug introduced by
The variable d3 seems to be never declared. If this is a global, consider adding a /** global: d3 */ 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...
11
        .attr('width', diameter)
12
        .attr('height', diameter);
13
14
15
    var bubble = d3.layout.pack()
16
        .size([diameter, diameter])
17
        .padding(3)
18
        .value(function (d) {
19
            return d.ccn;
20
        });
21
22
    var nodes = bubble.nodes(json)
23
        .filter(function (d) {
24
            return !d.children;
25
        }); // filter out the outer bubble*
26
27
    var vis = svg.selectAll('circle')
28
        .data(nodes, function (d) {
29
            return d.name;
30
        });
31
32
    vis.enter().append('circle')
33
        .attr('transform', function (d) {
34
            return 'translate(' + d.x + ',' + d.y + ')';
35
        })
36
        .attr('r', function (d) {
37
            return d.r;
38
        })
39
        .style("fill", function (d) {
40
            if (d.mi > 85) {
41
                return '#8BC34A';
42
            } else if (d.mi > 69) {
43
                return '#FFC107';
44
            } else {
45
                return '#F44336';
46
            }
47
        })
48
        .attr("transform", function (d) {
49
            return "translate(" + d.x + "," + d.y + ")";
50
        })
51
        .on('mouseover', function (d) {
52
            var text = '<strong>' + d.name + '</strong>'
53
                + "<br />Cyclomatic Complexity : " + d.ccn
54
                + "<br />Maintainability Index: " + d.mi;
55
            d3.select('.tooltip').html(text);
0 ignored issues
show
Bug introduced by
The variable d3 seems to be never declared. If this is a global, consider adding a /** global: d3 */ 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
            d3.select(".tooltip").style("opacity", 1);
57
        })
58
        .on('mousemove', function () {
59
            d3.select(".tooltip")
0 ignored issues
show
Bug introduced by
The variable d3 seems to be never declared. If this is a global, consider adding a /** global: d3 */ 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...
60
                .style("left", (d3.event.pageX + 5) + "px")
61
                .style("top", (d3.event.pageY + 5) + "px");
62
        })
63
        .on('mouseout', function () {
64
            d3.select(".tooltip").style("opacity", 0);
0 ignored issues
show
Bug introduced by
The variable d3 seems to be never declared. If this is a global, consider adding a /** global: d3 */ 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...
65
        });
66
67
    d3.select("body")
68
        .append("div")
69
        .attr("class", "tooltip")
70
        .style("opacity", 0);
71
72
}