-
Notifications
You must be signed in to change notification settings - Fork 1
/
index1.html
170 lines (145 loc) · 4.31 KB
/
index1.html
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
<!DOCTYPE html>
<html>
<head>
<meta name="google-site-verification" content="rIPxGMXZWDK5NZjZeKISPiZVZUe3buiLBJPn8eoeAfg" />
<div id="embed-api-auth-container"></div>
<div id="chart-container"></div>
<div id="view-selector-container"></div>
<div id="chart-1-container"></div>
<div id="chart-2-container"></div>
<div id="view-selector-1-container"></div>
<div id="view-selector-2-container"></div>
<script>
(function(w,d,s,g,js,fs){
g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(f){this.q.push(f);}};
js=d.createElement(s);fs=d.getElementsByTagName(s)[0];
js.src='https://apis.google.com/js/platform.js';
fs.parentNode.insertBefore(js,fs);js.onload=function(){g.load('analytics');};
}(window,document,'script'));
</script>
<script>
gapi.analytics.ready(function() {
/**
* Authorize the user immediately if the user has already granted access.
* If no access has been created, render an authorize button inside the
* element with the ID "embed-api-auth-container".
*/
gapi.analytics.auth.authorize({
container: 'embed-api-auth-container',
clientid: '809144664705-3noitj3d2soobtpss0magsjfi9uf2dri.apps.googleusercontent.com'
});
/**
* Create a new ViewSelector instance to be rendered inside of an
* element with the id "view-selector-container".
*/
var viewSelector = new gapi.analytics.ViewSelector({
container: 'view-selector-container'
});
// Render the view selector to the page.
viewSelector.execute();
/**
* Create a new DataChart instance with the given query parameters
* and Google chart options. It will be rendered inside an element
* with the id "chart-container".
*/
var dataChart = new gapi.analytics.googleCharts.DataChart({
query: {
metrics: 'ga:sessions',
dimensions: 'ga:date',
'start-date': '30daysAgo',
'end-date': 'yesterday'
},
chart: {
container: 'chart-container',
type: 'LINE',
options: {
width: '100%'
}
}
});
/**
* Render the dataChart on the page whenever a new view is selected.
*/
viewSelector.on('change', function(ids) {
dataChart.set({query: {ids: ids}}).execute();
});
/**
* Create a ViewSelector for the first view to be rendered inside of an
* element with the id "view-selector-1-container".
*/
var viewSelector1 = new gapi.analytics.ViewSelector({
container: 'view-selector-1-container'
});
/**
* Create a ViewSelector for the second view to be rendered inside of an
* element with the id "view-selector-2-container".
*/
var viewSelector2 = new gapi.analytics.ViewSelector({
container: 'view-selector-2-container'
});
// Render both view selectors to the page.
viewSelector1.execute();
viewSelector2.execute();
/**
* Create the first DataChart for top countries over the past 30 days.
* It will be rendered inside an element with the id "chart-1-container".
*/
var dataChart1 = new gapi.analytics.googleCharts.DataChart({
query: {
metrics: 'ga:entrances, ga:pageviews',
dimensions: 'ga:pagePath',
'start-date': '30daysAgo',
'end-date': 'yesterday',
'max-results': 15,
sort: '-ga:entrances'
},
chart: {
container: 'chart-1-container',
type: 'PIE',
options: {
width: '100%',
pieHole: 4/9
}
}
});
/**
* Create the second DataChart for top countries over the past 30 days.
* It will be rendered inside an element with the id "chart-2-container".
*/
var dataChart2 = new gapi.analytics.googleCharts.DataChart({
query: {
metrics: 'ga:sessions',
dimensions: 'ga:sourceMedium',
'start-date': '30daysAgo',
'end-date': 'yesterday',
'max-results': 15,
sort: '-ga:sessions'
},
chart: {
container: 'chart-2-container',
type: 'PIE',
options: {
width: '100%',
pieHole: 4/9
}
}
});
/**
* Update the first dataChart when the first view selecter is changed.
*/
viewSelector1.on('change', function(ids) {
dataChart1.set({query: {ids: ids}}).execute();
});
/**
* Update the second dataChart when the second view selecter is changed.
*/
viewSelector2.on('change', function(ids) {
dataChart2.set({query: {ids: ids}}).execute();
});
});
</script>
<title>Testing this out</title>
</head>
<body>
</body>
</html>