analytics.js
4.62 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
$(
function() {
$.ajax(
{
url: "/admin/ajax/analytics",
type: "POST",
success: function(data) {
// Replacing top data
$('#sessions')
.animateNumber({number: data.sessions}, 2000);
$('#users')
.animateNumber({number: data.users}, 2000);
$('#views')
.animateNumber({number: data.views}, 2000);
$('#newusers')
.animateNumber({number: data.newusers}, 2000);
// Building main chart
var chart = AmCharts.makeChart(
"chartdiv", {
"type": "serial",
'dataProvider': data.plot,
'categoryField': 'day',
'categoryAxis': {
'labelFrequency': 5
},
'graphs': [
{
'balloon': {
"drop": true,
"adjustBorderColor": false,
"color": "#ffffff"
},
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"bulletSize": 5,
"hideBulletsCount": 50,
"lineThickness": 2,
"title": "red line",
"useLineColorForBulletBorder": true,
"valueField": "users",
"balloonText": "<span style='font-size:18px;'>Users: [[users]]</span>",
"lineColor": '#9ABCC3'
},
{
'balloon': {
"drop": true,
"adjustBorderColor": false,
"color": "#ffffff"
},
"bullet": "round",
"bulletBorderAlpha": 1,
"bulletColor": "#FFFFFF",
"bulletSize": 5,
"hideBulletsCount": 50,
"lineThickness": 2,
"title": "red line",
"useLineColorForBulletBorder": true,
"valueField": "sessions",
"balloonText": "<span style='font-size:18px;'>Sessions: [[sessions]]</span>",
"lineColor": '#A8E3D6'
}
],
'chartCursor': {
"pan": true,
"valueLineEnabled": true,
"valueLineBalloonEnabled": true,
"cursorAlpha": 1,
"cursorColor": "#1ABB9C",
"limitToGraph": "g1",
"valueLineAlpha": 0.2,
"valueZoomable": true
}
}
);
// Building pie chart
var pie = AmCharts.makeChart(
"piediv", {
"type": "pie",
'dataProvider': data.pie,
"titleField": "category",
"valueField": "column-1",
'colors': [
"#A8E3D6",
"#9ABCC3"
]
}
);
// Replacing table stabs
$('#browsers')
.replaceWith(data.browsers);
$('#cities')
.replaceWith(data.cityes);
$('#countries')
.replaceWith(data.countries);
$('.yt-loader')
.remove();
}
}
)
}
);