-
Notifications
You must be signed in to change notification settings - Fork 0
/
LearningTracker_script_sample.js
executable file
·208 lines (177 loc) · 3.96 KB
/
LearningTracker_script_sample.js
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
var metricNames = ['Sessions per week',
'Average length of a session',
'Average time between sessions',
'Forum sessions',
'Weekly assessment answers submitted',
'Timeliness of weekly assessment submission'];
var metricUnits = ['h',
'',
'',
'',
'',
'h'];
var values = [0.3,0,0,7,12,92];
var lastWeek = [8.9,3,11,14,69,72];
var thisWeek = [10.3,10,22,23,73,70];
function getSeriesValue(chart, i) {
if(chart.points[i].series.name == 'You')
return values[chart.x/60];
else if(chart.points[i].series.name == 'Average graduate last week')
return lastWeek[chart.x/60];
else
return thisWeek[chart.x/60];
}
function timeStamp() {
var now = new Date();
var date = [ now.getFullYear(), now.getMonth() + 1, now.getDate() ];
var time = [ now.getHours(), now.getMinutes(), now.getSeconds() ];
for ( var i = 1; i < 3; i++ ) {
if ( time[i] < 10 ) {
time[i] = "0" + time[i];
}
}
if( date[1] < 10 ) {
date[1] = "0" + date[1];
}
return date.join("-") + "Z" + time.join(":");
}
function loadWidget() {
var user_id = '123451';
$('#container').highcharts({
chart: {
polar: true,
style: {
fontFamily: 'Open Sans, sans-serif'
},
type: 'area',
events: {
load: function () {
var category = user_id + '_week8';
gaPC('send', 'event', category, 'load_' + timeStamp());
}
}
},
exporting: {
chartOptions: { // specific options for the exported image
plotOptions: {
series: {
dataLabels: {
enabled: true
}
}
}
},
scale: 3,
fallbackToExportServer: true
},
title: {
text: 'Learning tracker',
style: {
align: 'left'
}
},
credits: {
enabled: false
},
legend: {
reversed: true
},
pane: {
startAngle: 0,
endAngle: 360
},
xAxis: {
tickInterval: 60,
min: 0,
max: 360,
labels: {
formatter: function () {
return metricNames[this.value/60];
}
},
gridLineWidth: 1
},
yAxis: {
min: 0,
max: 10,
gridLineWidth: 1,
labels: {
enabled: false
},
tickPositions: [0, 5, 10],
visible: true
},
plotOptions: {
series: {
allowPointSelect: true,
pointStart: 0,
pointInterval: 60,
cursor: 'pointer',
marker: {
symbol: 'diamond',
radius: 3
}
},
column: {
pointPadding: 0,
groupPadding: 0
}
},
tooltip: {
shared: true,
formatter: function () {
var tooltip_text = '<b>' + metricNames[this.x/60] + '</b>';
var unit = metricUnits[this.x/60];
for (i = this.points.length - 1; i >= 0; i--) {
tooltip_text += '<br/>' + this.points[i].series.name + ': <b>' + getSeriesValue(this, i) + ' ' + unit + '</b>';
}
return tooltip_text;
},
},
series: [
{
type: 'line',
name: 'Average graduate this week',
color: 'rgba(188, 64, 119, 0.5)',
data: [2.5, 3.7, 2.1, 2, 7.2, 3.7],
visible: false,
events: {
show: function () {
gaPC('send', 'event', user_id + '_week8', 'show-this-week_' + timeStamp());
},
hide: function () {
gaPC('send', 'event', user_id + '_week8', 'hide-this-week_' + timeStamp());
}
}
},
{
name: 'Average graduate last week',
color: 'rgba(255, 255, 102, 0.5)',
data: [2.6, 4, 2.1, 1.9, 8.2, 3.6
],
events: {
show: function () {
gaPC('send', 'event', user_id + '_week8', 'show-last-week_' + timeStamp());
},
hide: function () {
gaPC('send', 'event', user_id + '_week8', 'hide-last-week_' + timeStamp());
}
}
},
{
name: 'You',
color: 'rgba(144, 202, 249, 0.5)',
data: [7.4, 3.3, 1.2, 3.4, 7.4, 0.5
],
events: {
show: function () {
gaPC('send', 'event', user_id + '_week8', 'show-you_' + timeStamp());
},
hide: function () {
gaPC('send', 'event', user_id + '_week8', 'hide-you_' + timeStamp());
}
}
}]
});
}
loadWidget();