Commit 2a2199551f17968548a8bb98a58ca7e32d35faa9
1 parent
a194dccd
ga
Showing
1 changed file
with
3 additions
and
58 deletions
Show diff stats
backend/views/report/index.php
| @@ -20,10 +20,6 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -20,10 +20,6 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 20 | <h1><?= Html::encode($this->title) ?></h1> | 20 | <h1><?= Html::encode($this->title) ?></h1> |
| 21 | </div> | 21 | </div> |
| 22 | 22 | ||
| 23 | - <div id="embed-api-auth-container"></div> | ||
| 24 | - <div id="chart-container"></div> | ||
| 25 | - <div id="view-selector-container"></div> | ||
| 26 | - | ||
| 27 | <script> | 23 | <script> |
| 28 | (function(w,d,s,g,js,fs){ | 24 | (function(w,d,s,g,js,fs){ |
| 29 | g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}}; | 25 | g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}}; |
| @@ -33,64 +29,13 @@ $this->params['breadcrumbs'][] = $this->title; | @@ -33,64 +29,13 @@ $this->params['breadcrumbs'][] = $this->title; | ||
| 33 | }(window,document,'script')); | 29 | }(window,document,'script')); |
| 34 | </script> | 30 | </script> |
| 35 | 31 | ||
| 36 | - <script> | 32 | + <div id="embed-api-auth-container"></div> |
| 33 | + <div id="chart-container"></div> | ||
| 34 | + <div id="view-selector-container"></div> | ||
| 37 | 35 | ||
| 38 | - gapi.analytics.ready(function() { | ||
| 39 | - | ||
| 40 | - /** | ||
| 41 | - * Authorize the user immediately if the user has already granted access. | ||
| 42 | - * If no access has been created, render an authorize button inside the | ||
| 43 | - * element with the ID "embed-api-auth-container". | ||
| 44 | - */ | ||
| 45 | - gapi.analytics.auth.authorize({ | ||
| 46 | - container: 'embed-api-auth-container', | ||
| 47 | - clientid: '119240817' | ||
| 48 | - }); | ||
| 49 | - | ||
| 50 | - | ||
| 51 | - /** | ||
| 52 | - * Create a new ViewSelector instance to be rendered inside of an | ||
| 53 | - * element with the id "view-selector-container". | ||
| 54 | - */ | ||
| 55 | - var viewSelector = new gapi.analytics.ViewSelector({ | ||
| 56 | - container: 'view-selector-container' | ||
| 57 | - }); | ||
| 58 | - | ||
| 59 | - // Render the view selector to the page. | ||
| 60 | - viewSelector.execute(); | ||
| 61 | - | ||
| 62 | - | ||
| 63 | - /** | ||
| 64 | - * Create a new DataChart instance with the given query parameters | ||
| 65 | - * and Google chart options. It will be rendered inside an element | ||
| 66 | - * with the id "chart-container". | ||
| 67 | - */ | ||
| 68 | - var dataChart = new gapi.analytics.googleCharts.DataChart({ | ||
| 69 | - query: { | ||
| 70 | - metrics: 'ga:sessions', | ||
| 71 | - dimensions: 'ga:date', | ||
| 72 | - 'start-date': '30daysAgo', | ||
| 73 | - 'end-date': 'yesterday' | ||
| 74 | - }, | ||
| 75 | - chart: { | ||
| 76 | - container: 'chart-container', | ||
| 77 | - type: 'LINE', | ||
| 78 | - options: { | ||
| 79 | - width: '100%' | ||
| 80 | - } | ||
| 81 | - } | ||
| 82 | - }); | ||
| 83 | 36 | ||
| 84 | 37 | ||
| 85 | - /** | ||
| 86 | - * Render the dataChart on the page whenever a new view is selected. | ||
| 87 | - */ | ||
| 88 | - viewSelector.on('change', function(ids) { | ||
| 89 | - dataChart.set({query: {ids: ids}}).execute(); | ||
| 90 | - }); | ||
| 91 | 38 | ||
| 92 | - }); | ||
| 93 | - </script> | ||
| 94 | 39 | ||
| 95 | <?php | 40 | <?php |
| 96 | 41 |