forked from mihi-tr/nn-oneyear
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.html
341 lines (286 loc) · 7.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
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
<!DOCTYPE html>
<html>
<head>
<title>Netneutrality - shifting issues</title>
<style>
body {
font-family: open sans, helvetica, Arial, sans-serif;
color:#fff;
background-color: #0A0E11;
}
a {
color:#fe0;
}
h1 {
color: rgb(255, 245, 0);
margin: 20px 14px;
font-weight: normal;
}
svg.togglevis > g.data {
visibility: hidden;
}
svg > g.data {
opacity: 0.2;
transition:opacity .3s;
}
svg > g.data > text {
visibility: hidden;
font-family: open sans, helvetica, sans;
font-size: 0.7em;
}
svg > g.data > circle {
fill: #0099FF;
}
svg > g.data:hover > circle,
svg > g.data:hover > line {
fill: #FF0;
stroke: #FF0;
}
svg > g.data:hover,
svg> g.selected {
opacity: .7;
z-Index: 999;
}
svg > g.selected > line {
stroke: #1FFF00;
}
svg > g.selected > circle {
fill: #1FFF00;
}
svg > g.selected > text,
svg > g:hover > text {
visibility: visible;
}
svg.togglevis > g.data.selected {
visibility: visible;
}
svg > g > line {
stroke: #0099FF;
}
g.axis > g.tick > line {
stroke: #999;
stroke-width: 1;
}
g.axis > path {
opacity: 0;
}
g.axis > g.tick > text, svg > text {
fill: #999;
font-size:12px;
}
.data > text {
fill:yellow;
text-shadow: #000 0px 0px 4px, #000 0px 0px 4px, #000 0px 0px 4px;
}
ul#control {
list-style: none;
padding: 0 0 0 1005px;
max-width: 700px;
margin: -20px 0 0;
}
ul#control > li {
float:left;
width: 185px;
padding: 3px 5px 3px 6px;
border-left: #00579C 6px solid;
background: rgba(84, 129, 170, .2);
margin: 0 12px 2px 0;
cursor: pointer;
color: #CFCFCF;
border-radius: 2px;
font-size:.85em;
}
ul#control > li.selected {
background: rgba(36, 107, 197, 0.7);
border-left: #29CE00 6px solid;
box-shadow: rgba(0, 224, 255, 0.2) 0 0 11px;
}
#toggleall {
border: 1px solid #61B3FF;
color: #ccc;
background-color: #000;
text-transform: uppercase;
border-radius: 4px;
padding: 4px 10px;
margin: 0 0 0 14px;
cursor:pointer;
font-size:.6em;
}
div#gd {
width: 870px;
z-index: 9;
position: absolute;
}
#description {
font-size: .9em;
color: #ccc;
margin: 10px 39px;
line-height: 1.4em;
}
</style>
</head>
<body>
<h1>How did shaping of ISPs change last year?</h1>
<button id='toggleall'>show none</button>
<div id="gd">
<div id="graph">
</div>
<div id="description">
<p>
One year ago we started the <a
href="http://netneutralitymap.org">NetNeutrality Map</a> - a map displaying the status
of netneutrality in the world. It always displays data one year back - so
right now we have two years worth of data and we can ask ourselves: do ISPs
worldwide shape more or less?</p>
<p>The visualization above, shows the percentage of shaped tests for the
period 2011-09-01 to 2012-09-01, the one on the right for 2012-09-01 to
2013-09-01. The bigger a circle, the more tests were made in this
country. You can select countries by clicking on them on the left.
</p>
<p>
Interestingly, providers seemed to shape less last year, than the year
before - only in Korea, there seems to be more shaping this year than last
year.
</p>
</div>
</div>
<ul id="control">
</ul>
<script src="vendor/js/d3.v3.min.js"></script>
<script src="vendor/js/underscore-min.js"></script>
<script src="vendor/js/jquery-1.10.2.min.js"></script>
<script>
var width=800;
var height=600;
var max_r=30;
var min_r=5;
var distance=max_r*2.5;
svg=d3.select('#graph')
.append('svg')
.attr('width',width+210)
.attr('height',height);
d3.csv('ccodes.csv',function(ccodes) {
ccodes=_.reduce(ccodes, function(x,y) { x[y.Code]=y.Country; return x},{})
d3.csv('all.csv',function(d) {
t=_.map(d,function(x) { return parseInt(x.total)});
var rscale=d3.scale.sqrt()
.domain([_.min(t),_.max(t)])
.range([min_r,max_r]);
var yscale=d3.scale.linear()
.domain([0,100])
.range([distance/2,height-(distance/2)]);
var axis=d3.svg.axis().scale(yscale)
.orient('left');
data=_.filter(_.reduce(d,function(x,y) { if (x[y.CC]) {
x[y.CC].push(y);
}
else {
x[y.CC]=[y];
}
return x;
},{}),function(x) { return x.length==2 })
/**
* select a node
* @param d string id
**/
function selCountry (d) {
if (d3.select('#'+d).attr('class')=="selected") {
d3.select('#'+d).attr('class','');
d3.select('#data-'+d).attr('class','data');
}
else {
d3.select('#'+d).attr('class','selected');
d3.select('#data-'+d).attr('class','data selected');
}
}
svg.selectAll('g')
.data(data)
.enter()
.append('g')
.attr('id',function(d) { return "data-"+d[0].CC })
.attr('class','data')
.on('click',function(d) {sel(d[0].CC)});
svg.append('g')
.attr('class','axis')
.attr('transform','translate(35,0)')
.call(axis);
svg.append('line')
.attr('x1',distance)
.attr('x2',distance)
.attr('y1',height-30)
.attr('y2',height-36)
.attr('stroke','#999')
svg.append('text')
.text('2011-2012')
.attr('x',distance)
.attr('y',height-10)
.attr('text-anchor','middle');
svg.append('line')
.attr('x1',width-distance)
.attr('x2',width-distance)
.attr('y1',height-30)
.attr('y2',height-36)
.attr('stroke','#999')
svg.append('text')
.text('2012-2013')
.attr('x',width-distance)
.attr('y',height-10)
.attr('text-anchor','middle');
svg.append('text')
.text('shaped (%)')
.attr('x',45)
.attr('y',20)
.attr('text-anchor','middle');
svg.selectAll('g.data')
.append('circle')
.attr('r',function(d) { return rscale(d[0].total);})
.attr('cx',distance)
.attr('cy',function(d) { return yscale(d[0].percent);})
.append('title')
.text(function(d) { return ccodes[d[0].CC] + ": "+ d[0].percent+"% shaped"});
svg.selectAll('g.data')
.append('circle')
.attr('r',function(d) { return rscale(d[1].total);})
.attr('cx',width-distance)
.attr('cy',function(d) { return yscale(d[1].percent);})
.append('title')
.text(function(d) { return ccodes[d[0].CC] + ": " +d[1].percent+"% shaped"});
svg.selectAll('g.data')
.append('text')
.attr('x',width-distance + 20)
.attr('y',function(d) { return yscale(d[1].percent);})
.text(function(d) { return ccodes[d[0].CC] + ": " +d[1].percent+"% shaped"});
svg.selectAll('g.data')
.append('line')
.attr('x1',distance)
.attr('x2',width-distance)
.attr('y1',function(d) {return yscale(d[0].percent);})
.attr('y2',function(d) {return yscale(d[1].percent);})
.style('stroke-width',function(d)
{return (rscale(_.min([d[0].total,d[1].total]))) }) ;
cc=_.filter(_.uniq(_.map(data,function(x) { return x[0].CC})),
function(x) { return ccodes[x]!=undefined});
console.log(cc);
var control=d3.select("#control");
control.selectAll("li")
.data(cc)
.enter()
.append("li")
.text(function(d) { return ccodes[d]})
.attr('id',function(d) { return (d)})
.on('click', selCountry )
})
var ta = d3.select('#toggleall')
.on('click', function () {
if (svg.attr('class') === 'togglevis') {
svg.attr('class', '');
ta.text('show all');
} else {
svg.attr('class', 'togglevis');
ta.text('show none');
}
});
})
</script>
</body>
</html>