-
Notifications
You must be signed in to change notification settings - Fork 7
/
index.html
261 lines (237 loc) · 12.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
<!DOCTYPE html>
<html>
<head>
<title>Northern Ireland Elections: Results - ElectionsNI</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="https://cdn.jsdelivr.net/lodash/4.11.1/lodash.min.js"></script>
<script type="text/javascript" src="http://d3js.org/d3.v3.js"></script>
<script type="text/javascript" src="http://d3js.org/d3.hexbin.v0.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/json5/0.3.0/json5.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/vega/2.5.2/vega.min.js"></script>
<link rel="stylesheet" href="/website/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="/website/css/style.css" media="screen, handheld" />
<link rel="stylesheet" type="text/css" href="/website/css/overview.css" media="screen, handheld" />
<link rel="stylesheet" type="text/css" href="/website/css/enhanced.css" media="screen and (min-width: 60.5em)" />
<link rel="stylesheet" type="text/css" href="/website/css/stages.css" media="screen, handheld" />
<link rel="stylesheet" type="text/css" href="/website/css/transfers.css" media="screen, handheld" />
<link rel="icon" type="image/png" href="/website/image/favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="/website/image/favicon-16x16.png" sizes="16x16" />
<!--[if (lt IE 9)&(!IEMobile)]>
<link rel="stylesheet" type="text/css" href="enhanced.css" />
<![endif]-->
<meta name="description" content="Generating crowdsourced open data, live results and data visualisations for the Northern Ireland Assembly Elections 2017." />
<meta name="keywords" content="assembly, elections, open data, northern ireland, 2016, 2017, AE16, AE17, crowdsource, results, single transferable vote, stv, constituency, candidate, odi belfast, open government network, nicva, voting, #AE17, tally, count, electoral"
/>
<meta name="author" content="Bob Harper">
<meta name="robots" content="index, follow">
<meta name="revisit-after" content="1 month">
<meta name="twitter:card" content="summary" />
<meta name="twitter:site" content="@electionsni" />
<meta name="twitter:creator" content="@odibelfast" />
<meta property="og:url" content="http://electionsni.org" />
<meta property="og:title" content="Elections NI #AE17" />
<meta property="og:description" content="Generating crowdsourced open data, live results and data visualisations for the Northern Ireland Assembly Elections 2017." />
<meta property="og:image" content="http://electionsni.org/website/image/banner.png" />
<!-- data, elections, ni -->
</head>
<style>
#charttooltip {
font-size: 12px;
position: absolute;
height: auto;
padding: 10px;
color: #ffffff;
background-color: #000000;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
-webkit-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
-moz-box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
box-shadow: 4px 4px 10px rgba(0, 0, 0, 0.4);
pointer-events: none;
}
#charttooltip.hidden {
display: none;
}
</style>
<body>
<div id="wrap">
<header>
<h1><a href = "/">Elections NI</a></h1>
<p>Open data for the Assembly Elections #AE17</p>
</header>
<label for="show-menu" class="show-menu">Menu</label>
<input type="checkbox" id="show-menu" role="button">
<div id='cssmenu'>
<ul>
<li><a href='/constituencies'><span>Constituencies</span></a></li>
<li class='active'><a href='/results'><span>Results</span></a></li>
<li><a href='/candidates'><span>Candidates</span></a></li>
<li><a href='/data'><span>Data</span></a></li>
<li class='last'><a href='/about'><span>About</span></a></li>
</ul>
</div>
<div class="cta">
<strong>#GE2017: we are not covering the 2017 General Election, however you can find candidates at <a href="https://whocanivotefor.co.uk">Who Can I Vote For?</a></strong>
<div id="seats_summary" style="background-color: #ffffff; margin: auto; color: #212121; border-bottom: solid; border-bottom-width: 1px;"></div>
</div>
<div class="content">
<div id="overview_container" class="row">
<div id="overview_matrix"></div>
<div id="party_matrix"></div>
</div>
<div class="row">
<h2 id="number-elected" class="row"></h2>
<form>
<label for="year-radio-group">Choose year:</label>
<div id="year-radio-group" class="form-group">
<label class="radio-inline">
<input type="radio" name="year" value="2017" checked onchange="getdata(2017)"> 2017
</label>
<label class="radio-inline">
<input type="radio" name="year" value="2016" onchange="getdata(2016)"> 2016
</label>
<label class="radio-inline">
<input type="radio" name="year" value="2011" onchange="getdata(2011)"> 2011
</label>
</div>
<label for="sort-radio-group">Sort by:</label>
<div id="sort-radio-group" class="form-group">
<label class="radio-inline">
<input type="radio" name="sorter" value="party" checked onchange='pushdata(data,"Party_Name","asc");visualise();'> Party
</label>
<label class="radio-inline">
<input type="radio" name="sorter" value="constituency" onchange='pushdata(data,"Constituency_Number","asc");visualise();'> Constituency
</label>
<label class="radio-inline">
<input type="radio" name="sorter" value="fpv" onchange='pushdata(data,"Candidate_First_Pref_Votes","desc");visualise();'> 1st Pref Votes
</label>
</div>
</form>
<div id="chart"></div>
</div>
<div id="charttooltip" class="hidden">
<span id="constituencyname" style="font-weight: bold"></span></br>
<span id="name"></span></br>
<span id="party" style="color: red"></span></br>
<span id="fpv"></span></br>
</div>
<div class="row">
<h2>Visualisations</h2>
<p>Choose a constituency and year.</p>
<div id="menuBar">
<select id="constituencySelect">
</select>
<select id="yearSelect">
<option>2017</option>
<option>2016</option>
<option>2011</option>
</select>
</div>
</div>
<div class="row">
<h3>Transfers</h3>
<div id="stageNumbers"></div>
<div id="controls">
<a href="#Again" id="again" class="fa fa-step-backward"></a>
<a href="#Pause" id="pause-replay" class="fa fa-pause"></a>
<a href="#Next" id="step" class="fa fa-step-forward"></a>
</div>
<div id="quota"></div>
<div id="animation"></div>
</div>
<div class="row">
<h3>Count Matrix</h3>
<div id="overview_container">
<div id="count_matrix"></div>
</div>
<div id="matrixtooltip"></div>
<p>Red = Eliminated, Green = Elected</p>
</div>
<div class="row">
<h3>Party to Party Transfers</h3>
<div class="alert alert-info" role="alert">This matrix summarises the percentage of transfers between candidates from each party. It is based on only those count stages with a transfer from one single candidate. It is only indicative of the transfers that were calculated during
the actual count process, and cannot account for all ballots cast in a constituency.</div>
<h4 id="transfers_constituency"></h4>
<div id="transfers"></div>
<p>N/T = votes not transferred</p>
</div>
<p>Thanks to James Bligh (<a href="http://twitter.com/anamates" target="_blank" title="External Link">@anamates</a>) for sharing the <a href="https://github.com/NICVA/electionsni/blob/master/website/js/stages.js" target="_blank" title="External Link">code</a> for the transfers animation.</p>
</div>
</div>
<div id="footer">
Project by <a href="http://belfast.theodi.org">ODI Belfast</a> at <a href="http://www.nicva.org">NICVA</a> and the <a href="http://www.opengovernment.org.uk/about/ni-ogn/">Open Government Network NI</a></br>
<a href="http://www.nicva.org"><img src="/website/image/nicva500.png" height="75px" align="middle"></a>
<a href="http://belfast.theodi.org"><img src="/website/image/odibelfast500.png" height="75px" align="middle"></a>
<a href="http://www.opengovernment.org.uk/about/ni-ogn/"><img src="/website/image/ognni500.png" height="75px" align="middle"></a>
</div>
<!--Load local scripts-->
<script type="text/javascript" src="/website/js/d3hexbin.js"></script>
<script type="text/javascript" src="/website/js/script.js"></script>
<script type="text/javascript" src="/website/js/stages2.js"></script>
<script src="/website/js/transfers.js"></script>
<script src="/website/js/overview_matrix2.js"></script>
<script type="text/javascript">
// for AE16-LIVE we don't want to chace json in case users don't see the updates
$(document).ready(function() {
$.ajaxSetup({
cache: false
});
});
seatsSummary();
// tooltip
$(document).bind('mousemove', function(e) {
$('#matrixtooltip').css({
"left": e.pageX + 20,
"top": e.pageY
});
});
var year = $("#yearSelect :selected").text();
$.getJSON('/' + year + "/NI/all-constituency-info.json", function(data) {
var constituencies = data.Constituencies;
var constituencySelect = $("#constituencySelect");
var yearSelect = $("#yearSelect");
$.each(constituencies, function(i, constituency) {
var name = constituency.Constituency_Name;
var folder = name.toLowerCase().replace(" and ", "-").replace(/\s/, "-");
$(constituencySelect).append($("<option/>").val(folder).text(name))
})
constituencySelect.change(function() {
var constituencyFolder = $("#constituencySelect :selected").val();
var year = $("#yearSelect :selected").text();
countMatrix(year, constituencyFolder);
animateStages(year, constituencyFolder);
})
yearSelect.change(function() {
var constituencyFolder = $("#constituencySelect :selected").val();
var year = $("#yearSelect :selected").text();
getTransfersData(year);
countMatrix(year, constituencyFolder);
animateStages(year, constituencyFolder);
})
var constituencyFolder = $("#constituencySelect :selected").val();
var year = $("#yearSelect :selected").text();
getTransfersData(year);
countMatrix(year, constituencyFolder);
animateStages(year, constituencyFolder);
})
</script>
<script>
(function(i, s, o, g, r, a, m) {
i['GoogleAnalyticsObject'] = r;
i[r] = i[r] || function() {
(i[r].q = i[r].q || []).push(arguments)
}, i[r].l = 1 * new Date();
a = s.createElement(o),
m = s.getElementsByTagName(o)[0];
a.async = 1;
a.src = g;
m.parentNode.insertBefore(a, m)
})(window, document, 'script', 'https://www.google-analytics.com/analytics.js', 'ga');
ga('create', 'UA-77063537-1', 'auto');
ga('send', 'pageview');
</script>
</body>
</html>