-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.js
executable file
·196 lines (181 loc) · 7.76 KB
/
code.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
listClub = [ 'CLUB AMOUR',
'CLUB INSALAN',
'CLUB 3D',
'CLUB FOG',
'CLUB ROBOT',
'CLUB INSAKURA',
'CLUB INSALIVE',
'CLUB INSATISFAIT(E)S',
'CLUB TRIP',
'CLUB BRICO',
'CLUB ENVIRONNEMENT',
'CLUB IMPRO',
'CLUB PHOTOS VIDEOS',
'CLUB CHILL'];
dataTableUtilisations = [[ 'Indice',
'KPOTE',
'INSALAN',
'CLUB3D',
'FOG18',
'ROBOT',
'INSAKURA',
'LIVE',
'CLITO',
'RACLETTE18',
'BRICO19',
'RECYCLE',
'PUTACLIC',
'PHOTOVIDEO',
'TOUTSCHUSS' ]];
dataTableActivations = [[ 'Indice',
'KPOTE',
'INSALAN',
'CLUB3D',
'FOG18',
'ROBOT',
'INSAKURA',
'LIVE',
'CLITO',
'RACLETTE18',
'BRICO19',
'RECYCLE',
'PUTACLIC',
'PHOTOVIDEO',
'TOUTSCHUSS' ]];
dataTablePoints = [[ 'Indice',
'KPOTE',
'INSALAN',
'CLUB3D',
'FOG18',
'ROBOT',
'INSAKURA',
'LIVE',
'CLITO',
'RACLETTE18',
'BRICO19',
'RECYCLE',
'PUTACLIC',
'PHOTOVIDEO',
'TOUTSCHUSS' ]];
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawChart);
// Callback that creates and populates a data table,
// instantiates the pie chart, passes in the data and
// draws it.
function drawChart() {
// Create the data tables.
createTables();
var dataUtil = google.visualization.arrayToDataTable(dataTableUtilisations)
var dataActiv = google.visualization.arrayToDataTable(dataTableActivations)
var dataPoints = google.visualization.arrayToDataTable(dataTablePoints)
// Set chart options
var optionsUtil = {'title':'Utilisations par Club',
'width':1000,
'height':700};
var optionsActiv = {'title':'Activations par Club',
'width':1000,
'height':700};
var optionsPoints = {'title':'Points par Club',
'width':1000,
'height':700};
// Instantiate and draw our chart, passing in some options.
var utilisationChart = new google.visualization.LineChart(document.getElementById('utilisation_chart'));
utilisationChart.draw(dataUtil, optionsUtil);
var navigationChart = new google.visualization.LineChart(document.getElementById('activation_chart'));
navigationChart.draw(dataActiv, optionsActiv);
var pointsChart = new google.visualization.LineChart(document.getElementById('points_chart'));
pointsChart.draw(dataPoints, optionsPoints);
document.querySelector('h2').style.display='none';
document.querySelector('img').style.display='none';
}
function determineDate(minutes)
{
//We don't know how Google Charts' API samples the x-axis
// so we need this tricky function to calculate what's the date corresponding to the 'minutes' value
round = 0
semirange = 0.5
newmin = minutes/720;
hours = (12+Math.floor(minutes/60))%24
if(newmin < round+semirange){
return 'mardi 18, '+hours+'h'}
else if(newmin>round+1-semirange && newmin <round+1+semirange){
return 'mardi 18, '+hours+'h'}
else if(newmin>round+2-semirange && newmin <round+2+semirange){
return 'mercredi 19, '+hours+'h'}
else if(newmin>round+3-semirange && newmin <round+3+semirange){
return 'mercredi 19, '+hours+'h'}
else if(newmin>round+4-semirange && newmin <round+4+semirange){
return 'jeudi 20, '+hours+'h'}
else if(newmin>round+5-semirange && newmin <round+5+semirange){
return 'jeudi 20, '+hours+'h'}
else if(newmin>round+6-semirange && newmin <round+6+semirange){
return 'vendredi 21, '+hours+'h'}
else if(newmin>round+7-semirange && newmin <round+7+semirange){
return 'vendredi 21, '+hours+'h'}
else if(newmin>round+8-semirange && newmin <round+8+semirange){
return 'samedi 22, '+hours+'h'}
else if(newmin>round+9-semirange && newmin <round+9+semirange){
return 'samedi 22, '+hours+'h'}
else if(newmin>round+10-semirange && newmin <round+10+semirange){
return 'dimanche 23, '+hours+'h'}
else if(newmin>round+11-semirange && newmin <round+11+semirange){
return 'dimanche 23, '+hours+'h'}
else if(newmin>round+12-semirange && newmin <round+12+semirange){
return 'lundi 24, '+hours+'h'}
else if(newmin>round+13-semirange && newmin <round+13+semirange){
return 'lundi 24, '+hours+'h'}
else if(newmin>round+14-semirange && newmin <round+14+semirange){
return 'mardi 25, '+hours+'h'}
else if(newmin>round+15-semirange && newmin <round+15+semirange){
return 'mardi 25, '+hours+'h'}
else if(newmin>round+16-semirange && newmin <round+16+semirange){
return 'mercredi 26, '+hours+'h'}
else if(newmin>round+17-semirange && newmin <round+17+semirange){
return 'mercredi 26, '+hours+'h'}
else if(newmin>round+18-semirange && newmin <round+18+semirange){
return 'jeudi 27, '+hours+'h'}
else if(newmin>round+19-semirange && newmin <round+19+semirange){
return 'jeudi 27, '+hours+'h'}
else if(newmin>round+20-semirange && newmin <round+20+semirange){
return 'vendredi 28, '+hours+'h'}
else if(newmin>round+21-semirange && newmin <round+21+semirange){
return 'vendredi 28, '+hours+'h'}
else if(newmin>round+22-semirange && newmin <round+22+semirange){
return 'samedi 29, '+hours+'h'}
else if(newmin>round+23-semirange && newmin <round+23+semirange){
return 'samedi 29, '+hours+'h'}
else if(newmin>round+24-semirange && newmin <round+24+semirange){
return 'dimanche 30, '+hours+'h'}
else if(newmin>round+25-semirange && newmin <round+25+semirange){
return 'dimanche 30, '+hours+'h'}
else if(newmin>round+26-semirange && newmin <round+26+semirange){
return 'lundi 1, '+hours+'h'}
else{
return ''}
}
function createTables()
{
for(var index = 1; index < dataTableUtilisations[0].length; index++)
{
promoCode = dataTableUtilisations[0][index]
dataOnpromoCode = document.getElementsByClassName(promoCode)
for(var j = 0; j < dataOnpromoCode.length; j++)
{
nbrUtil = dataOnpromoCode[j].querySelector('.utilisation').innerText;
nbrActiv = dataOnpromoCode[j].querySelector('.activation').innerText;
nbrPoints = dataOnpromoCode[j].querySelector('.points').innerText;
if(index==1) //First promo code
{
jdate = determineDate(j)
dataTableUtilisations.push([jdate])
dataTableActivations.push([jdate])
dataTablePoints.push([jdate])
}
dataTableUtilisations[j+1].push(parseInt(nbrUtil,10));
dataTableActivations[j+1].push(parseInt(nbrActiv,10));
dataTablePoints[j+1].push(parseInt(nbrPoints,10));
}
}
}