-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
131 lines (115 loc) · 4.15 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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.js"></script>
<link
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous">
<style>
.chart div {
font: 10px sans-serif;
background-color: steelblue;
text-align: right;
padding: 3px;
margin: 1px;
color: white;
}
</style>
<title>IIT Kharagpur General Championships Scores 2016-17</title>
</head>
<body style="margin: 20px;">
<div class="container-of-charts">
<h2>Sports GC</h2>
<div class="chart-sports">
</div>
<h2>Tech GC</h2>
<div class="chart-tech">
</div>
<h2>Soc-Cult GC</h2>
<div class="chart-soccult">
</div>
</div>
<p style="position: absolute; right: 10px; top: 10px">Powered by
<a href="http://awaaziitkgp.org/GC201617.php?page=gc"
target="_blank">Awaaz IIT KGP
</a>
</p>
<p style="position: absolute; right: 10px; top: 30px">
<a href="https://icyflame.github.io/gc-viz/sports"
target="_blank">Sports GC</a>
</p>
<p style="position: absolute; right: 10px; top: 50px">
<a href="https://icyflame.github.io/gc-viz/soccult"
target="_blank">Soc-Cult GC</a>
</p>
<p style="position: absolute; right: 10px; top: 70px">
<a href="https://icyflame.github.io/gc-viz/tech"
target="_blank">Tech GC</a>
</p>
<script>
cumulative_sum = [];
var file_names = ["sports.csv", "soccult.csv", "tech.csv"];
var gc_names = ["Sports", "Soc-Cult", "Tech"];
for (filename in file_names) {
console.log(filename + "-> " + gc_names[filename]);
d3.csv(file_names[filename], function(err, hall_list) {
var gc_points = [];
var gc_name = "";
for(iter in hall_list) {
var sum = 0;
for (key in hall_list[iter]) {
if (key.search("hall") >= 0) {
gc_name = key.split("-")[0];
continue;
}
var pts = +hall_list[iter][key];
sum = sum + pts;
}
if (!isNaN(sum)) {
gc_points.push({
"name": hall_list[iter][gc_name + "-hall"],
"value": sum
});
}
}
cumulative_sum.push({
"name": gc_name.toLowerCase(),
"value": gc_points
});
var max_data = d3.max(gc_points, function(d) { return d.value; });
var find_mul = d3.scaleLinear()
.domain([0, max_data])
.range([0, 420]);
d3.select(".chart-" + gc_name)
.attr("class", "chart")
.selectAll("div")
.data(gc_points)
.enter().append("div")
.style("width", function(d) { return find_mul(d.value) + "px"; })
.text(function(d) { return d.name + ", " + d.value + " points"; });
});
/*
for(gc in gcs) {
var halls_keys = ["hall","Debate","Eastern Vocals"," Bengali Elocution","Sketching","Hindi Dramatics","Cartooning","Western Vocals","Eastern Instrumentals","Choreography","{ role: 'annotation' }"];
var data = [["Nehru",0,0,0,60,100,60,60,35,40,355],["Azad",35,0,0,25,60,0,35,0,100,255],["LLR",60,60,0,35,0,12,0,0,0,167],["Patel",0,25,25,0,0,0,25,60,0,135],["LBS",0,0,60,0,0,35,0,25,0,120],["RP",25,0,0,0,0,12,0,0,60,97],["SN",0,0,0,0,40,0,0,0,0,40],["MS",0,0,35,0,0,0,0,0,0,35],["BRH",0,35,0,0,0,0,0,0,0,35]];
var max_data = -5000;
for (var i = 0; i < data.length; ++i) {
if (data[i][data[i].length-1] > max_data) {
max_data = data[i][data[i].length-1];
}
}
d3.select(".chart")
.selectAll("div")
.data(data)
.enter().append("div")
.style("width", function(d) { return find_mul(d[d.length-1]) + "px"; })
.text(function(d) { return d[0] + ", " + d[d.length-1] + " points"; });
}
*/
}
</script>
</body>
</html>