Blame view

backend/web/js/analytics.js 4.62 KB
6b69a279   Alexey Boroda   -GA js ready
1
2
3
  $(
      function() {
          $.ajax(
4acbd19d   Alexey Boroda   -Bar tabs
4
              {
6b69a279   Alexey Boroda   -GA js ready
5
6
7
8
9
                  url: "/admin/ajax/analytics",
                  type: "POST",
                  success: function(data) {
                      // Replacing top data
                      $('#sessions')
198ca6c0   Alexey Boroda   -Animations ready...
10
                          .animateNumber({number: data.sessions}, 2000);
6b69a279   Alexey Boroda   -GA js ready
11
                      $('#users')
198ca6c0   Alexey Boroda   -Animations ready...
12
                          .animateNumber({number: data.users}, 2000);
6b69a279   Alexey Boroda   -GA js ready
13
                      $('#views')
198ca6c0   Alexey Boroda   -Animations ready...
14
                          .animateNumber({number: data.views}, 2000);
6b69a279   Alexey Boroda   -GA js ready
15
                      $('#newusers')
198ca6c0   Alexey Boroda   -Animations ready...
16
                          .animateNumber({number: data.newusers}, 2000);
6b69a279   Alexey Boroda   -GA js ready
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
                      // 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);
c8905ae2   Alexey Boroda   -Pre loader ready
97
98
                      $('.yt-loader')
                          .remove();
6b69a279   Alexey Boroda   -GA js ready
99
                  }
4acbd19d   Alexey Boroda   -Bar tabs
100
              }
6b69a279   Alexey Boroda   -GA js ready
101
          )
4acbd19d   Alexey Boroda   -Bar tabs
102
      }
6b69a279   Alexey Boroda   -GA js ready
103
  );