-
Notifications
You must be signed in to change notification settings - Fork 3
/
new-editors.html
214 lines (184 loc) · 5.55 KB
/
new-editors.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
<html>
<title>Indic Wikipedia: New Editors Every Month</title>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<script src="lib/jquery/jquery.tipsy.js"></script>
<script src="http://d3js.org/d3.v3.min.js"></script>
<link href="lib/bootstrap/css/bootstrap.min.css" rel="stylesheet">
<link href="lib/bootstrap/css/bootstrap-responsive.min.css" rel="stylesheet">
<link href="/indicwiki/css/tipsy.css" rel="stylesheet">
<link href="css/app.css" rel="stylesheet">
</head>
<body>
<div id="wrap">
<div class="container" id="calendar">
<div class="row-fluid">
<h1 class="text-center">Indic Wikipedia: New Editors Every Month</h1>
<div class="span3 offset4">
<div id="legend">
<ul class="Greens">
<li class="q0-9"></li>
<li class="q1-9"></li>
<li class="q2-9"></li>
<li class="q4-9"></li>
<li class="q5-9"></li>
<li class="q6-9"></li>
<li class="q7-9"></li>
<li class="q8-9"></li>
</ul>
<p class="less">0</p>
<p class="more">>25</p>
</div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div id="vis2002"></div>
</div>
<div class="span6">
<div id="vis2003"></div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div id="vis2004"></div>
</div>
<div class="span6">
<div id="vis2005"></div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div id="vis2006"></div>
</div>
<div class="span6">
<div id="vis2007"></div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div id="vis2008"></div>
</div>
<div class="span6">
<div id="vis2009"></div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div id="vis2010"></div>
</div>
<div class="span6">
<div id="vis2011"></div>
</div>
</div>
<div class="row-fluid">
<div class="span6">
<div id="vis2012"></div>
</div>
</div>
</div>
<div id="push"></div>
</div>
<div id="footer">
<div class="container">
<p class="muted credit">© <a href="http://cis-india.org">The Centre for Internet and Society</a> | Built by <a href="http://twitter.com/geohacker">@geohacker</a> and <a href="http://twitter.com/ajantriks">@ajantriks</a>.</p>
</div>
</div>
<script>
var color = d3.scale.quantize()
.domain([0, 25])
.range(d3.range(9).map(function(d) { return "q" + d + "-9"; }));
colors = d3.scale.category20c();
var languages = [{name:'Hindi', code:'hi'},
{name:'Bengali', code:'bn'},
{name:'Marathi', code:'mr'},
{name: 'Telugu', code:'te'},
{name: 'Tamil', code:'ta'},
{name: 'Urdu', code:'ur'},
{name: 'Kannada', code:'kn'},
{name: 'Gujarati', code:'gu'},
{name: 'Sindhi', code:'sd'},
{name: 'Bhojpuri', code:'bh'},
{name: 'Malayalam', code:'ml'},
{name: 'Oriya', code:'or'},
{name: 'Punjabi', code:'pa'},
{name: 'Assamese', code:'as'},
{name: 'Newari', code:'new'},
{name: 'Kashmiri', code:'ks'},
{name: 'Nepali', code:'ne'},
{name: 'Bishnupriya', code:'bpy'},
{name: 'Sanskrit', code:'sa'},
{name: 'Pali', code:'pi'}];
var months = [{name: 'January', code: 'jan'},
{name: 'February', code: 'feb'},
{name: 'March', code: 'mar'},
{name: 'April', code: 'apr'},
{name: 'May', code: 'may'},
{name: 'June', code: 'jun'},
{name: 'July', code: 'jul'},
{name: 'August', code: 'aug'},
{name: 'September', code: 'sep'},
{name: 'October', code: 'oct'},
{name: 'November', code: 'nov'},
{name: 'December', code: 'dec'}];
var years = ['2004', '2005', '2006', '2007', '2008', '2009', '2010', '2011', '2012'];
var data;
var format = d3.time.format("%Y/%m/%d")
var parseNumber = d3.format(',');
function createTiles(year) {
var title = "<p class='year text-center'>"+year+"</p>"
var html = title+'<table id="tiles" class="front">';
html += '<tr><th><div> </div></th>';
for (var l = 0; l < languages.length; l++) {
html += '<th class="h' + languages[l].code + '">' + languages[l].code + '</th>';
}
html += '</tr>';
for (var m = 0; m < months.length; m++) {
html += '<tr class="'+months[m].code+'">';
html += '<th>' + months[m].code + '</th>';
for (var l = 0; l < languages.length; l++) {
html += '<td id="' + months[m].code + languages[l].code + '" class=" Greens d' + m + ' h' + l + '"><div class="tile"></div></td>';
}
html += '</tr>';
}
html += '</table>';
d3.select('#vis'+year).html(html);
}
d3.csv('/indicwiki/data/new_editors.csv', function(csv) {
data = csv;
initialize();
});
function filterYear(year) {
return (function(d) {return (format.parse(d.date).getFullYear() == year);});
}
function initialize() {
for (var i=(years.length-1); i>=0; i--) {
yearData = data.filter(filterYear(years[i]));
createTiles(years[i]);
updateTiles(yearData, years[i]);
}
$('.tile').tipsy({
gravity: 'w',
html: true,
title: function() {
var y = $(this).parents().eq(4).attr('id').substring(3);
return $(this).attr('lang') + '<br>'+ $(this).attr('month') +' '+ y +'<br>' + 'New Editors: ' + parseNumber($(this).attr('data'));
}
});
}
function updateTiles(yearData, year) {
for (var m = 0; m < months.length; m++) {
for (var l = 0; l < languages.length; l++) {
var tileColor = color(yearData[m][languages[l].code]);
var sel = '#vis'+year+' #'+months[m].code+languages[l].code+' .tile';
selected = d3.select(sel);
selected.classed(tileColor, true);
selected.attr('data', yearData[m][languages[l].code]);
selected.attr('lang', languages[l].name);
selected.attr('month', months[m].name);
}
}
}
</script>
</body>
</html>