-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
368 lines (312 loc) · 17.8 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
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Masterclass Showdown 2014: Class Rankings</title>
<script type="text/javascript" src="d3/d3.v3.js"></script>
<style>
svg .pumpkin {
fill: yellow;
stroke: orange;
stroke-width: 5;
}
svg .axis path,
svg .axis line {
fill: none;
stroke: #444;
shape-rendering: crispEdges;
}
svg .axis text {
font-family: sans-serif;
font-size: 11px;
}
p.caption {
font-size:.8em;
padding-top:1em;
padding-bottom:1em;
text-align:center;
}
div.container {
width:800px;
margin-left: auto;
margin-right: auto;
}
div.bar {
display: inline-block;
width: 20px;
height: 75px; /* We'll override this later */
background-color: teal;
margin-right:2px;
}
</style>
</head>
<body>
<div class="container">
<div align=center>
<img src="competition-web-header.png" />
</div>
<p class="caption"> All classes that are participating and have started practising are listed below.
Classes are listed in the order of their current ranking.
You can see the changes in ranking of the classes in the weekly rankings.
A single class will be <strong>highlighted</strong> if you move your cursor over the class name.</p>
<svg id="rankings" width=1000 height=1600></svg>
</div>
<script type="text/javascript">
var weekcount = 9; /* add a fake last week */
var schoolcount = 20;
var w = 700;
var h = 1600;
var max = 1600;
var padding = 100;
var colours = ["yellow", "red", "green", "blue", "orange","brown","yellow"];
/*var svg = d3.select("body")
.append("svg")
.attr("width", w)
.attr("height", h);*/
var svg = d3.select("#rankings");
var dataset =
[
{name:"Roedean Academy: Gr 08 PM Maths", rankings: [ 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 ], score: 13422.2109233643 },
{name:"Herzlia: 103LJ", rankings: [ 11 , 5 , 8 , 8 , 8 , 9 , 2 , 2 , 2 ], score: 5552.7567182343 },
{name:"Roedean Academy: Gr 09 PM Maths", rankings: [ 3 , 2 , 3 , 3 , 2 , 2 , 3 , 3 , 3 ], score: 5403.2148642465 },
{name:"Herzlia: 106NM", rankings: [ 18 , 10 , 11 , 12 , 15 , 12 , 4 , 4 , 4 ], score: 5247.1836663049 },
{name:"Herzlia: 105NM", rankings: [ 23 , 7 , 9 , 10 , 11 , 10 , 5 , 5 , 5 ], score: 4388.8574142493 },
{name:"Olico: Gr 10 Maths", rankings: [ 6 , 4 , 4 , 4 , 5 , 3 , 6 , 6 , 6 ], score: 2928.564035964 },
{name:"Jeppe Girls: Gr 10U Maths SC", rankings: [ 27 , 3 , 2 , 2 , 3 , 4 , 7 , 7 , 7 ], score: 2369.1737987013 },
{name:"Roedean Academy: Gr 10 RB Maths", rankings: [ 5 , 8 , 7 , 5 , 4 , 5 , 8 , 8 , 8 ], score: 2019.78632946 },
{name:"Olico: Gr 09 Maths", rankings: [ 10 , 11 , 10 , 9 , 9 , 6 , 9 , 9 , 9 ], score: 1821.9709503072 },
{name:"Wynberg Girls' High School: GR10PS", rankings: [ 2 , 6 , 6 , 6 , 6 , 8 , 10 , 10 , 10 ], score: 1404.2511948052 },
{name:"Roedean Academy: Gr 11 RK Maths", rankings: [ 9 , 9 , 5 , 7 , 7 , 7 , 11 , 11 , 11 ], score: 1365.0683928572 },
{name:"Roedean School: Gr 11 Sci LK Class 1104", rankings: [ 42 , 25 , 27 , 20 , 10 , 11 , 12 , 12 , 12 ], score: 1211.6498686633 },
{name:"Roedean Academy: Gr 11 AB Science", rankings: [ 15 , 13 , 12 , 11 , 12 , 13 , 13 , 13 , 13 ], score: 835.0385638368 },
{name:"Creston College: Grade 9 PE", rankings: [ 12 , 14 , 14 , 15 , 14 , 15 , 14 , 14 , 14 ], score: 796.3724591793 },
{name:"Wynberg Girls' High School: GR10SP", rankings: [ 7 , 16 , 16 , 14 , 13 , 14 , 15 , 15 , 15 ], score: 715.9182113341 },
{name:"Jeppe Girls: Gr 10E Maths LT", rankings: [ 14 , 19 , 19 , 16 , 19 , 16 , 16 , 16 , 16 ], score: 599.9002164502 },
{name:"Wynberg Girls' High School: GR10EV", rankings: [ 4 , 12 , 13 , 13 , 16 , 17 , 17 , 17 , 17 ], score: 472.905799373 },
{name:"Reddam House Atlantic Sea Board: Graham10", rankings: [ 26 , 20 , 21 , 21 , 24 , 24 , 20 , 18 , 18 ], score: 467.4820804268 },
{name:"Roedean School: Gr 11 Sci LK Class 1101", rankings: [ 45 , 53 , 54 , 48 , 17 , 18 , 18 , 19 , 19 ], score: 432.0740334795 },
{name:"HeronBridge: Gr 09 SE Maths", rankings: [ 8 , 15 , 15 , 17 , 18 , 19 , 21 , 20 , 20 ], score: 389.0530833667 },
{name:"Creston College: Grade 10 PE", rankings: [ 38 , 46 , 48 , 52 , 53 , 47 , 19 , 21 , 21 ], score: 381.6 },
{name:"Roedean Academy: Gr 10 TN Science", rankings: [ 45 , 32 , 20 , 22 , 23 , 20 , 22 , 22 , 22 ], score: 322.4886219566 },
{name:"Wynberg Girls' High School: GR10JN", rankings: [ 16 , 18 , 18 , 19 , 21 , 22 , 23 , 23 , 23 ], score: 316.5298983625 },
{name:"Wynberg Girls' High School: GR11EV", rankings: [ 20 , 17 , 17 , 18 , 20 , 21 , 24 , 24 , 24 ], score: 286.0357142857 },
{name:"Wynberg Girls' High School: GR10CU", rankings: [ 13 , 21 , 22 , 23 , 25 , 25 , 26 , 25 , 25 ], score: 240.538729128 },
{name:"Roedean School: Gr 11 Sci AB Class 1102", rankings: [ 45 , 53 , 54 , 58 , 22 , 23 , 25 , 26 , 26 ], score: 225.7961538462 },
{name:"Wynberg Girls' High School: GR10DM", rankings: [ 19 , 23 , 25 , 27 , 29 , 29 , 28 , 27 , 27 ], score: 222.9460227273 },
{name:"Roedean School: Gr 10 Sci TN Class 1003", rankings: [ 43 , 41 , 24 , 26 , 28 , 28 , 29 , 28 , 28 ], score: 211.5612217769 },
{name:"Wynberg Girls' High School: GR11JN", rankings: [ 17 , 22 , 23 , 24 , 26 , 26 , 27 , 29 , 29 ], score: 191.3043478261 },
{name:"Roedean Academy: Gr 12 SM Science", rankings: [ 45 , 28 , 29 , 25 , 27 , 27 , 30 , 30 , 30 ], score: 175.3238906423 },
{name:"Wynberg Girls' High School: GR11PS", rankings: [ 24 , 24 , 26 , 28 , 30 , 30 , 31 , 31 , 31 ], score: 147.1363636364 },
{name:"Wynberg Girls' High School: GR11PM", rankings: [ 29 , 27 , 28 , 29 , 31 , 32 , 32 , 32 , 32 ], score: 138.0848214286 },
{name:"Creston College: Grade 8 PE", rankings: [ 40 , 40 , 44 , 41 , 37 , 31 , 33 , 33 , 33 ], score: 132.4776676328 },
{name:"Reddam House Atlantic Sea Board: Graham12", rankings: [ 44 , 31 , 34 , 34 , 36 , 39 , 36 , 34 , 34 ], score: 126.7933179425 },
{name:"Wynberg Girls' High School: GR10PM", rankings: [ 28 , 33 , 35 , 35 , 38 , 33 , 34 , 35 , 35 ], score: 124.3722077922 },
{name:"HeronBridge: Gr 08 SE Maths", rankings: [ 45 , 44 , 46 , 49 , 43 , 35 , 38 , 36 , 36 ], score: 117.8975153954 },
{name:"Wynberg Girls' High School: GR11DM", rankings: [ 21 , 26 , 30 , 30 , 32 , 34 , 35 , 37 , 37 ], score: 111.0527950311 },
{name:"Wynberg Girls' High School: GR11FB", rankings: [ 22 , 29 , 31 , 31 , 33 , 36 , 37 , 38 , 38 ], score: 94.6785714286 },
{name:"Wynberg Girls' High School: GR10FB", rankings: [ 25 , 30 , 32 , 32 , 34 , 37 , 39 , 39 , 39 ], score: 88.3846153846 },
{name:"CBC St John's Parklands: Gr 10 BZ", rankings: [ 39 , 47 , 37 , 38 , 41 , 42 , 44 , 40 , 40 ], score: 78.1159180126 },
{name:"HeronBridge: Gr 10 SE Maths", rankings: [ 35 , 43 , 33 , 33 , 35 , 38 , 40 , 41 , 41 ], score: 76.4757378985 },
{name:"Creston College: Grade 11 PE", rankings: [ 45 , 36 , 40 , 37 , 40 , 41 , 41 , 42 , 42 ], score: 72.9035714286 },
{name:"Roedean School: Gr 10 Sci TN Class 1004", rankings: [ 45 , 52 , 36 , 36 , 39 , 40 , 42 , 43 , 43 ], score: 67.1817930688 },
{name:"Wynberg Girls' High School: GR11DB", rankings: [ 30 , 34 , 39 , 40 , 44 , 44 , 43 , 44 , 44 ], score: 59.1488095238 },
{name:"Roedean School: Gr 10 Sci AB Class 1002", rankings: [ 34 , 37 , 38 , 39 , 42 , 43 , 45 , 45 , 45 ], score: 46.1821415354 },
{name:"Durban Girls College: Gr 10 Science MP", rankings: [ 31 , 35 , 41 , 42 , 45 , 45 , 46 , 46 , 46 ], score: 36.4615384615 },
{name:"Jeppe Girls: Gr 10D Maths AF", rankings: [ 32 , 38 , 42 , 43 , 46 , 46 , 47 , 47 , 47 ], score: 36.036 },
{name:"CBC St John's Parklands: Gr 11 BZ", rankings: [ 33 , 39 , 43 , 44 , 47 , 48 , 48 , 48 , 48 ], score: 28.3965517241 },
{name:"Jeppe Girls: Gr 11E Maths SC", rankings: [ 36 , 42 , 45 , 45 , 48 , 49 , 49 , 49 , 49 ], score: 25.5 },
{name:"Roedean Academy: Gr 12 EH Maths", rankings: [ 45 , 53 , 52 , 47 , 50 , 50 , 50 , 50 , 50 ], score: 24.4606141484 },
{name:"Roedean School: Gr 12 Sci LK Class 1203", rankings: [ 45 , 53 , 54 , 46 , 49 , 51 , 51 , 51 , 51 ], score: 17.125 },
{name:"De La Salle: Gr 11 KVW Sci Class X", rankings: [ 45 , 53 , 54 , 51 , 52 , 53 , 53 , 52 , 52 ], score: 12.1285714286 },
{name:"CBC St John's Parklands: Gr 12 BZ", rankings: [ 37 , 45 , 47 , 50 , 51 , 52 , 52 , 53 , 53 ], score: 9.990625 },
{name:"Jeppe Girls: Gr 10C Maths YS", rankings: [ 41 , 48 , 49 , 53 , 54 , 55 , 55 , 54 , 54 ], score: 6.6458333333 },
{name:"Durban Girls College: Gr 10 Science HM", rankings: [ 45 , 51 , 53 , 57 , 59 , 54 , 54 , 55 , 55 ], score: 6.5046556457 },
{name:"Reddam House Atlantic Sea Board: Graham11", rankings: [ 45 , 50 , 51 , 55 , 57 , 58 , 58 , 56 , 56 ], score: 6.1058823529 },
{name:"Durban Girls College: Gr 11 Science MP", rankings: [ 45 , 53 , 54 , 58 , 60 , 60 , 61 , 57 , 57 ], score: 5.8125 },
{name:"De La Salle: Gr 10 KVW Sci Class Z", rankings: [ 45 , 53 , 54 , 58 , 55 , 56 , 56 , 58 , 58 ], score: 5.71875 },
{name:"Covenant College: Gr 12 Maths DL", rankings: [ 45 , 49 , 50 , 54 , 56 , 57 , 57 , 59 , 59 ], score: 4.5 },
{name:"De La Salle: Gr 11 KVW Sci Class Z", rankings: [ 45 , 53 , 54 , 56 , 58 , 59 , 59 , 60 , 60 ], score: 3.5571428571 },
{name:"Roedean School: Gr 12 Sci AB Class 1202", rankings: [ 45 , 53 , 54 , 58 , 60 , 60 , 60 , 61 , 61 ], score: 1.98 }
];
var blue_to_brown = d3.scale.linear()
.domain([1, dataset.length])
//.range(["steelblue", "brown"])
.range(["#0088b4", "#ef6a2c"])
.interpolate(d3.interpolateLab);
/*
var dataset = [
];
for (var k=0; k<weekcount; k++)
{
var rankings = d3.shuffle(d3.range(1, schoolcount+1,1));
//var rankings = d3.range(1, schoolcount+1,1);
for (var j=0; j<schoolcount; j++)
{
if (k==0) {dataset.push(
{
name : "Class " + j ,
rankings : [],
score: 0
}
);}
if (k==weekcount -1)
{
dataset[j].rankings.push(dataset[j].rankings[k-1]);
dataset[j].score = 100 - dataset[j].rankings[k-1]*4;
}
else{dataset[j].rankings.push(rankings[j]);}
}
}
dataset.sort(function(a, b) {
return d3.ascending(a.rankings[a.rankings.length-1], b.rankings[b.rankings.length-1]);
});
*/
var widths = (w)/(dataset.length);
var xScale = d3.scale.ordinal()
.domain(d3.range(weekcount))
.rangeRoundBands([padding, w-2*padding]);
var yScale = d3.scale.ordinal()
.domain(d3.range(dataset.length))
.rangeRoundBands([padding/4, max-2*padding]);
var scoreScale = d3.scale.linear()
.domain([0,dataset[0].score])
.range([0, 100]);
var parallels = svg.selectAll("parallels")
.data(dataset[0].rankings)
.enter()
.append("line")
.attr("x1", function(d,i) {return xScale(i); })
.attr("x2", function(d,i) {return xScale(i);})
.attr("y1", function(d,i) {return yScale(dataset.length-1);})
.attr("y2", function(d,i) {return yScale(0);})
.attr("stroke-width",1)
.attr("stroke","#111");
var weeklabels = svg.selectAll("weeklabels")
.data(dataset[0].rankings)
.enter()
.append("text")
.attr("x", function (d,i) {return xScale(i);} )
.attr("y", function(d,i) { return yScale(0)- 20 ;} )
.attr("font-size", 10)
.attr("text-anchor", "middle")
.text(function(d,i){ if (i <dataset[0].rankings.length-1)
{return "Week "+ (i+1);}
else
{return "Current";}
});
var paths = svg.selectAll("paths")
.data(dataset)
.enter()
.append("path")
.attr("d", function(d,i)
{
var x = xScale(0);
var y = yScale(d.rankings[0]-1);
var result = "M "+ x + " "+ y +" L ";
for (var j = 0; j < d.rankings.length ; j++)
{
x = xScale(j);
y = yScale(d.rankings[j]-1);
result = result + x + " " + y +",";
}
return result;
})
.attr("class",function(d,i){ return "SchoolClass" +i; })
.attr("id",function(d,i){ return "pathSchoolClass" +i; })
.attr("fill","none")
.attr("stroke-width",1)
.attr("stroke",function(d,i){ return blue_to_brown(d.rankings[d.rankings.length-1]);});
var labels = svg.selectAll("schools")
.data(dataset)
.enter()
.append("text")
.attr("x", function(d,i) { return xScale(d.rankings.length-1) + 15;} )
.attr("y", function(d) { return yScale(d.rankings[d.rankings.length-1]-1)+5;} )
// .attr("text-anchor", "left")
.attr("font-size", 14)
.attr("class",function(d,i){ return "SchoolClass" +i; })
.classed("SchoolClass",true)
.attr("id",function(d,i){ return "SchoolClass" +i; })
//.attr("stroke",function(d,i){ return blue_to_brown(d[d.length-1]);})
.text(function(d,i){ return d.name;});
var scorebars = svg.selectAll("schools-scores")
.data(dataset)
.enter()
.append("rect")
.attr("x", function(d,i) { return xScale(dataset[0].rankings.length-1) + 400;} )
.attr("y", function(d,i) { return yScale(i)-5;} )
.attr("height", function(d,i) { return 10;} )
.attr("width", function(d,i) { return scoreScale(d.score);} )
.attr("fill",function(d,i){ return blue_to_brown(i);})
.attr("class",function(d,i){ return "SchoolClass" +i; })
.attr("id",function(d,i){ return "barSchoolClass" +i; })
.attr("stroke-width", 1)
.attr("stroke",function(d,i){ return "gray";});
var positions = svg.selectAll("positions")
.data(dataset)
.enter()
.append("text")
.attr("x", xScale(0) - 20 )
.attr("y", function(d,i) { return yScale(i) +7 ;} )
.attr("font-size", 14)
.attr("text-anchor", "end")
.text(function(d,i){ if (i ==0 ) { return "Position: "+ (i+1); } else { return i+1;}});
var xAxis = d3.svg.axis()
.scale(scoreScale)
.orient("bottom")
.ticks(5); //Set rough # of ticks
d3.selectAll(".SchoolClass")
.on("mouseover", function() {
var id = d3.select(this).attr("id");
svg.selectAll("path").attr("opacity",.4);
d3.select(this)
.attr("font-weight", "bold");
d3.selectAll("#path"+id)
.attr("stroke",function(d,i){ return blue_to_brown(d.rankings[d.rankings.length-1]);})
.attr("stroke-width", 5)
.attr("opacity",1);
d3.selectAll("#bar"+id)
.attr("stroke",function(d,i){ return "black";});
})
.on("mouseout", function() {
var id = d3.select(this).attr("id");
svg.selectAll("path").attr("stroke",function(d,i){ return blue_to_brown(d.rankings[d.rankings.length-1]);})
.attr("opacity",1);
d3.selectAll("."+id)
.attr("font-weight", "normal");
d3.selectAll("#path"+id)
.attr("stroke-width", 1);
d3.selectAll("#bar"+id)
.attr("stroke",function(d,i){ return "gray";});
}) ;
/*
svg.append("g")
.attr("class", "axis")
.attr("transform", "translate(" + ((xScale(5) + 135)) + ","+( yScale(schoolcount-1)+7)+")")
.call(xAxis);
*/
/*
var lines = svg.selectAll("lines")
.data(dataset)
.enter()
.append("line")
.attr("x1", function(d,i) {return 50+0*50;})
.attr("y1", function(d,i) {return 50+(d[0]-1)*50;})
.attr("x2", function(d,i) {return 50+1*50;})
.attr("y2", function(d,i) {return 50+(d[1]-1)*50;})
.attr("x3", function(d,i) {return 50+2*50;})
.attr("y3", function(d,i) {return 50+(d[2]-1)*50;})
.attr("x4", function(d,i) {return 50+3*50;})
.attr("y4", function(d,i) {return 50+(d[3]-1)*50;})
.attr("x5", function(d,i) {return 50+4*50;})
.attr("y5", function(d,i) {return 50+(d[4]-1)*50;})
.attr("x6", function(d,i) {return 50+5*50;})
.attr("y6", function(d,i) {return 50+(d[5]-1)*50;})
.attr("x7", function(d,i) {return 50+6*50;})
.attr("y7", function(d,i) {return 50+(d[6]-1)*50;})
.attr("stroke-width",2)
.attr("stroke",function(d,i){ if (i == 0) {return "black";}else{return "red";}});
*/
</script>
</body>
</html>