-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.html
236 lines (192 loc) · 5.13 KB
/
index.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
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<!DOCTYPE html>
<html>
<head>
<title>Qld Government Analytics</title>
<link rel="stylesheet" type="text/css" href="style.css">
<link href='https://fonts.googleapis.com/css?family=Source+Sans+Pro:300' rel='stylesheet' type='text/css'>
</head>
<body>
<div id="content">
<h1>
Queensland Government analytics
</h1>
<div id="area">
<div id="auth">
<section id="auth-button"></section>
</div>
<div id="select">
<div id="divtitle">Sessions by day: <b>Last 30 days</b></div>
<section id="view-selector"></section>
<section id="timeline"></section>
</div>
<div id="select2">
<div id="divtitle">Sessions by location: <b>Last 7 days</b></div>
<section id="view-selector-2"></section>
<section id="mapchart"></section>
</div>
<div id="select">
<div id="divtitle">Average Pageviews per Session: <b>Last 30 days</b></div>
<section id="view-selector-3"></section>
<section id="linechart"></section>
</div>
<div id="select2">
<div id="divtitle">Session by Device Type: <b>Last 30 days</b></div>
<section id="view-selector-4"></section>
<section id="piechart"></section>
</div>
</div>
</div>
<!-- Step 2: Load the library. -->
<script>
(function(w,d,s,g,js,fjs){
g=w.gapi||(w.gapi={});g.analytics={q:[],ready:function(cb){this.q.push(cb)}};
js=d.createElement(s);fjs=d.getElementsByTagName(s)[0];
js.src='https://apis.google.com/js/platform.js';
fjs.parentNode.insertBefore(js,fjs);js.onload=function(){g.load('analytics')};
}(window,document,'script'));
</script>
<script>
gapi.analytics.ready(function() {
// Step 3: Authorize the user.
var CLIENT_ID = '627232566188-lhhh7og01ddia6bok6kdtg95bgdcvscr.apps.googleusercontent.com';
gapi.analytics.auth.authorize({
container: 'auth-button',
clientid: CLIENT_ID,
});
// Step 4: Create the view selector.
var viewSelector = new gapi.analytics.ViewSelector({
container: 'view-selector'
});
var viewSelector2 = new gapi.analytics.ViewSelector({
container: 'view-selector-2'
});
var viewSelector3 = new gapi.analytics.ViewSelector({
container: 'view-selector-3'
});
var viewSelector4 = new gapi.analytics.ViewSelector({
container: 'view-selector-4'
});
// Step 5: Create the timeline chart.
var timeline = new gapi.analytics.googleCharts.DataChart({
reportType: 'ga',
query: {
'dimensions': 'ga:date',
'metrics': 'ga:sessions',
'start-date': '30daysAgo',
'end-date': 'today',
'filters': 'ga:region==Queensland',
},
chart: {
type: 'LINE',
container: 'timeline',
options: {
title: 'Daily Sessions',
curveType: 'function',
lineWidth: 0.5,
pointsVisible: 'false',
trendlines: {
0: {
color: 'orange',
lineWidth: 2,
opacity: 0.5,
type: 'exponential',
}
} // Finish trendlines
} // Finish the chart options
} // Finish the chart section
}); // Finish the overal timeline chart section
var linechart = new gapi.analytics.googleCharts.DataChart({
reportType: 'ga',
query: {
'metrics': 'ga:pageviewsPerSession',
'dimensions': 'ga:date',
'start-date': '30daysAgo',
'end-date': 'today',
'filters': 'ga:region==Queensland',
},
chart: {
container: 'linechart',
type: 'LINE',
options: {
width: '100%',
curveType: 'function',
lineWidth: 0.5,
pointsVisible: 'false',
trendlines: {
0: {
color: 'orange',
lineWidth: 2,
opacity: 0.5,
type: 'exponential',
}
}
}
}
});
var piechart = new gapi.analytics.googleCharts.DataChart({
query: {
'metrics': 'ga:sessions',
'dimensions': 'ga:deviceCategory',
'start-date': '30daysAgo',
'end-date': 'today',
'max-results': 5,
sort: '-ga:sessions',
'filters': 'ga:region==Queensland',
},
chart: {
container: 'piechart',
type: 'PIE',
options: {
width: '100%',
pieHole: 2/9,
}
}
});
var mapchart = new gapi.analytics.googleCharts.DataChart({
query: {
'metrics': 'ga:sessions',
'dimensions': 'ga:city',
'start-date': '30daysAgo',
'end-date': 'today',
'sort': '-ga:sessions',
'max-results': 10,
'filters': 'ga:region==Queensland',
},
chart: {
container: 'mapchart',
type: 'GEO',
options: {
title: 'Map of Sessions by Location',
width: '100%',
region: 'AU',
displayMode: 'markers',
markerOpacity: 0.7,
colorAxis: {colors: ['#ff6600', '#ff9900']},
}
}
});
// Step 6: Hook up the components to work together.
gapi.analytics.auth.on('success', function(response) {
viewSelector.execute();
viewSelector2.execute();
viewSelector3.execute();
viewSelector4.execute();
});
viewSelector.on('change', function(ids) {
var newIds = {
query: {ids: ids}}
timeline.set(newIds).execute();
});
viewSelector2.on('change', function(ids) {
mapchart.set({query: {ids: ids}}).execute();
});
viewSelector3.on('change', function(ids) {
linechart.set({query: {ids: ids}}).execute();
});
viewSelector4.on('change', function(ids) {
piechart.set({query: {ids: ids}}).execute();
});
});
</script>
</body>
</html>