Passed
Push — master ( 384962...a2213c )
by Benjamin
26:55 queued 19:06
created

T_IDENTIFIER   A

Complexity

Total Complexity 18
Complexity/F 2.57

Size

Lines of Code 1
Function Count 7

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 0
wmc 18
c 1
b 0
f 0
nc 6
mnd 2
bc 15
fnc 7
dl 0
loc 1
rs 10
bpm 2.1427
cpm 2.5714
noi 5
1
/** global: Analytics */
2
/** global: google */
3
/**
4
 * BaseChart
5
 */
6
Analytics.reports.BaseChart = Garnish.Base.extend(
0 ignored issues
show
Bug introduced by
The variable Garnish seems to be never declared. If this is a global, consider adding a /** global: Garnish */ 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...
7
    {
8
        $chart: null,
9
        $graph: null,
10
11
        localeDefinition: null,
12
13
        type: null,
14
        chart: null,
15
        chartOptions: null,
16
        data: null,
17
        period: null,
18
        options: null,
19
        visualization: null,
20
        drawing: false,
21
22
        init: function($element, data, localeDefinition, chartLanguage) {
23
            this.visualization = new Analytics.Visualization(
24
                {
25
                    chartLanguage: chartLanguage,
26
                    onAfterInit: $.proxy(function() {
27
                        this.$chart = $element;
28
                        this.$chart.html('');
29
                        this.$graph = $('<div class="chart" />').appendTo(this.$chart);
30
                        this.data = data;
31
                        this.localeDefinition = localeDefinition;
32
33
                        if (typeof(this.data.chartOptions) != 'undefined') {
34
                            this.chartOptions = this.data.chartOptions;
35
                        }
36
37
                        if (typeof(this.data.type) != 'undefined') {
38
                            this.type = this.data.type;
39
                        }
40
41
                        if (typeof(this.data.period) != 'undefined') {
42
                            this.period = this.data.period;
43
                        }
44
45
                        this.addListener(Garnish.$win, 'resize', 'resize');
0 ignored issues
show
Bug introduced by
The variable Garnish seems to be never declared. If this is a global, consider adding a /** global: Garnish */ 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...
46
47
                        this.initChart();
48
49
                        this.draw();
50
51
                        if (typeof(this.data.onAfterInit) != 'undefined') {
52
                            this.data.onAfterInit();
53
                        }
54
55
                    }, this)
56
                });
57
        },
58
59
        addChartReadyListener: function() {
60
            google.visualization.events.addListener(this.chart, 'ready', $.proxy(function() {
61
                this.drawing = false;
62
63
                if (typeof(this.data.onAfterDraw) != 'undefined') {
64
                    this.data.onAfterDraw();
65
                }
66
67
            }, this));
68
        },
69
70
        initChart: function() {
71
            this.$graph.addClass(this.type);
72
        },
73
74
        draw: function() {
75
            if (!this.drawing) {
76
                this.drawing = true;
77
78
                if (this.dataTable && this.chartOptions) {
79
80
                    this.chart.draw(this.dataTable, this.chartOptions);
81
                }
82
            }
83
        },
84
85
        resize: function() {
86
            if (this.chart && this.dataTable && this.chartOptions) {
87
                this.draw(this.dataTable, this.chartOptions);
88
            }
89
        },
90
    });