Passed
Push — develop ( 29629c...8f4c81 )
by Benjamin
07:10
created

Garnish.Base.extend.geo   B

Complexity

Conditions 5
Paths 5

Size

Total Lines 26
Code Lines 19

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 5
eloc 19
nc 5
nop 1
dl 0
loc 26
rs 8.9833
c 2
b 0
f 0
1
/** global: Analytics */
2
/** global: Garnish */
3
/**
4
 * Chart Options
5
 */
6
Analytics.ChartOptions = Garnish.Base.extend({}, {
7
    area: function(scale) {
8
        var options = this.defaults.area;
9
10
        switch (scale) {
11
            case 'week':
12
                options.hAxis.format = 'E';
13
                options.hAxis.showTextEvery = 1;
14
                break;
15
16
            case 'month':
17
                options.hAxis.format = 'MMM d';
18
                options.hAxis.showTextEvery = 1;
19
                break;
20
21
            case 'year':
22
                options.hAxis.showTextEvery = 1;
23
                options.hAxis.format = 'MMM yy';
24
                break;
25
        }
26
27
        return options;
28
    },
29
30
    table: function() {
31
        return this.defaults.table;
32
    },
33
34
    geo: function(dimension) {
35
        var options = this.defaults.geo;
36
37
        switch (dimension) {
38
            case 'ga:city':
39
                options.displayMode = 'markers';
40
                break;
41
42
            case 'ga:country':
43
                options.resolution = 'countries';
44
                options.displayMode = 'regions';
45
                break;
46
47
            case 'ga:continent':
48
                options.resolution = 'continents';
49
                options.displayMode = 'regions';
50
                break;
51
52
            case 'ga:subContinent':
53
                options.resolution = 'subcontinents';
54
                options.displayMode = 'regions';
55
                break;
56
        }
57
58
        return options;
59
    },
60
61
    pie: function() {
62
        return this.defaults.pie;
63
    },
64
65
    field: function() {
66
        return {
67
            theme: 'maximized',
68
            legend: 'none',
69
            backgroundColor: '#fdfdfd',
70
            colors: ['#058DC7'],
71
            areaOpacity: 0.1,
72
            lineWidth: 4,
73
            height: 120,
74
            hAxis: {
75
                //format:'MMM yy',
76
                format: 'MMM d',
77
                // format: 'E',
78
                textPosition: 'in',
79
                textStyle: {
80
                    color: '#058DC7'
81
                },
82
                showTextEvery: 1,
83
                baselineColor: '#fff',
84
                gridlines: {
85
                    color: 'none'
86
                }
87
            },
88
            vAxis: {
89
                textPosition: 'in',
90
                textStyle: {
91
                    color: '#058DC7'
92
                },
93
                baselineColor: '#ccc',
94
                gridlines: {
95
                    color: '#f4f4f4'
96
                },
97
                // viewWindow: {min:0, max: 10},
98
                minValue: 0,
99
                maxValue: 10,
100
                format: '#'
101
            }
102
        };
103
    },
104
105
    defaults: {
106
        area: {
107
            theme: 'maximized',
108
            legend: 'none',
109
            backgroundColor: 'transparent',
110
            colors: ['#058DC7'],
111
            areaOpacity: 0.1,
112
            pointSize: 7,
113
            lineWidth: 4,
114
            chartArea: {},
115
            hAxis: {
116
                //format:'MMM yy',
117
                // format: 'MMM d',
118
                format: 'E',
119
                textPosition: 'in',
120
                textStyle: {
121
                    color: '#058DC7'
122
                },
123
                showTextEvery: 1,
124
                baselineColor: '#fff',
125
                gridlines: {
126
                    color: 'none'
127
                }
128
            },
129
            vAxis: {
130
                textPosition: 'in',
131
                textStyle: {
132
                    color: '#058DC7'
133
                },
134
                baselineColor: '#ccc',
135
                gridlines: {
136
                    color: '#fafafa'
137
                },
138
                // viewWindow: {min:0, max: 10},
139
                minValue: 0,
140
                maxValue: 10,
141
                format: '#'
142
            }
143
        },
144
145
        geo: {
146
            // height: 282
147
            displayMode: 'auto'
148
        },
149
150
        pie: {
151
            theme: 'maximized',
152
            height: 282,
153
            pieHole: 0.5,
154
            legend: {
155
                alignment: 'center',
156
                position: 'top'
157
            },
158
            chartArea: {
159
                top: 40,
160
                height: '82%'
161
            },
162
            sliceVisibilityThreshold: 1 / 120
163
        },
164
165
        table: {
166
            // page: 'enable'
167
        }
168
    }
169
});
170