-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
294 lines (290 loc) · 18.7 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
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<title>Nova Scotia Open Data</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="css/dashboard.css">
<link rel="stylesheet" type="text/css" href="css/style.css">
<!-- Custom styles for this template -->
<script src="https://code.jquery.com/jquery-3.3.1.min.js" integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8=" crossorigin="anonymous"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="js/d3.js"></script>
</head>
<body data-gr-c-s-loaded="true">
<div class="container-fluid bg-white p-0">
<div class="row"><img src="image/nova_scotia_logo.png" height="60px" width="215px" style="padding: 10px; margin-left: 20px"></div>
<div class="row p-0" id="top-bar">
<nav class="navbar navbar-expand-lg p-0" style="margin-left: 20px">
<ul class="navbar-nav p-0" id="menu">
<li class="nav-item">
<a class="nav-link" href="#">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Catalogue</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">User's Guide</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Developers</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Survey</a>
</li>
<li class="nav-item active">
<a class="nav-link" href="#">Index Dashboard</a>
</li>
</ul></nav>
</div>
</div>
<!-- <a class="navbar-brand col-sm-3 col-md-2 mr-0 text-center" href="#">TrajExp</a> -->
<!-- <input class="form-control form-control-light w-100" type="text" placeholder="Search" aria-label="Search"> -->
<div class="container-fluid p-0 fix-top-m4">
<main role="main" class="px-0" id="main-content">
<div class="row p-1">
<div class="col-3" id="left-panel">
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-1 mt-4 mb-1 text-muted">
<span >Select Indices to View</span>
<a data-toggle="collapse" role="button" class="d-flex align-items-center text-muted" href="#select-index">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle svg-icon">
<path d="M13.962,8.885l-3.736,3.739c-0.086,0.086-0.201,0.13-0.314,0.13S9.686,12.71,9.6,12.624l-3.562-3.56C5.863,8.892,5.863,8.611,6.036,8.438c0.175-0.173,0.454-0.173,0.626,0l3.25,3.247l3.426-3.424c0.173-0.172,0.451-0.172,0.624,0C14.137,8.434,14.137,8.712,13.962,8.885 M18.406,10c0,4.644-3.763,8.406-8.406,8.406S1.594,14.644,1.594,10S5.356,1.594,10,1.594S18.406,5.356,18.406,10 M17.521,10c0-4.148-3.373-7.521-7.521-7.521c-4.148,0-7.521,3.374-7.521,7.521c0,4.147,3.374,7.521,7.521,7.521C14.148,17.521,17.521,14.147,17.521,10"></path>
</svg>
</a>
</h6>
<div class="collapse m-2" id="select-index">
<div class="form-group">
<div id="select-indices">
<div class="row form-group">
<div class="col-md-auto">
<select class="form-control form-control-sm">
<option selected disabled>Select an index</option>
<option>Criminality</option>
<option>Healthcare</option>
</select>
</div>
<div class="col">
<button class="btn text-muted" style="padding: 0px; padding-top: 2px" onclick="addIndex(this)"><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle">
<path d="M14.613,10c0,0.23-0.188,0.419-0.419,0.419H10.42v3.774c0,0.23-0.189,0.42-0.42,0.42s-0.419-0.189-0.419-0.42v-3.774H5.806c-0.23,0-0.419-0.189-0.419-0.419s0.189-0.419,0.419-0.419h3.775V5.806c0-0.23,0.189-0.419,0.419-0.419s0.42,0.189,0.42,0.419v3.775h3.774C14.425,9.581,14.613,9.77,14.613,10 M17.969,10c0,4.401-3.567,7.969-7.969,7.969c-4.402,0-7.969-3.567-7.969-7.969c0-4.402,3.567-7.969,7.969-7.969C14.401,2.031,17.969,5.598,17.969,10 M17.13,10c0-3.932-3.198-7.13-7.13-7.13S2.87,6.068,2.87,10c0,3.933,3.198,7.13,7.13,7.13S17.13,13.933,17.13,10"></path>
</svg></button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function addIndex(btn) {
btn.remove('.btn');
$('#select-indices').append(`
<div class="row form-group">
<div class="col-md-auto">
<select class="form-control form-control-sm">
<option selected disabled>Select an index</option>
<option>Criminality</option>
<option>Healthcare</option>
</select>
</div>
<div class="col">
<button class="btn text-muted" style="padding: 0px; padding-top: 2px" onclick="addIndex(this)"><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle"><path d="M14.613,10c0,0.23-0.188,0.419-0.419,0.419H10.42v3.774c0,0.23-0.189,0.42-0.42,0.42s-0.419-0.189-0.419-0.42v-3.774H5.806c-0.23,0-0.419-0.189-0.419-0.419s0.189-0.419,0.419-0.419h3.775V5.806c0-0.23,0.189-0.419,0.419-0.419s0.42,0.189,0.42,0.419v3.775h3.774C14.425,9.581,14.613,9.77,14.613,10 M17.969,10c0,4.401-3.567,7.969-7.969,7.969c-4.402,0-7.969-3.567-7.969-7.969c0-4.402,3.567-7.969,7.969-7.969C14.401,2.031,17.969,5.598,17.969,10 M17.13,10c0-3.932-3.198-7.13-7.13-7.13S2.87,6.068,2.87,10c0,3.933,3.198,7.13,7.13,7.13S17.13,13.933,17.13,10"></path></svg></button>
</div>
</div>`);
}
</script>
<div class="row m-1">
<button class="btn btn-sm btn-outline-secondary" onclick="viewIndices(this)">View</button>
</div>
<script type="text/javascript">
function viewIndices(obj) {
console.log('View indices!');
d3.select("#pie0-text").text(theMap.indexData[0].name);
d3.select("#pie1-text").text(theMap.indexData[1].name);
d3.select("#piechart-view").attr("hidden", null);
d3.select("#rank-view").attr("hidden", null);
d3.select("#year-slider").attr("hidden", null);
pieChart("#pie0", theMap.getIndexParamsForCounty(0, 'Halifax'), theMap.getIndexParamNames(0));
pieChart("#pie1", theMap.getIndexParamsForCounty(1, 'Halifax'), theMap.getIndexParamNames(1));
updateMap(theMap.indexData[0].data);
d3.select("#map-index-name").text(theMap.indexData[0].name);
d3.select('#index-label').style('visibility', 'visible');
}
</script>
</div>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-1 mt-4 mb-1 text-muted">
<span >Create an Index</span>
<a data-toggle="collapse" role="button" class="d-flex align-items-center text-muted" href="#create-index">
<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle svg-icon">
<path d="M13.962,8.885l-3.736,3.739c-0.086,0.086-0.201,0.13-0.314,0.13S9.686,12.71,9.6,12.624l-3.562-3.56C5.863,8.892,5.863,8.611,6.036,8.438c0.175-0.173,0.454-0.173,0.626,0l3.25,3.247l3.426-3.424c0.173-0.172,0.451-0.172,0.624,0C14.137,8.434,14.137,8.712,13.962,8.885 M18.406,10c0,4.644-3.763,8.406-8.406,8.406S1.594,14.644,1.594,10S5.356,1.594,10,1.594S18.406,5.356,18.406,10 M17.521,10c0-4.148-3.373-7.521-7.521-7.521c-4.148,0-7.521,3.374-7.521,7.521c0,4.147,3.374,7.521,7.521,7.521C14.148,17.521,17.521,14.147,17.521,10"></path>
</svg>
</a>
</h6>
<div class="collapse m-2" id="create-index">
<div class="form-group">
<label class="form-label" id="create-name">Name</label>
<input class="form-control form-control-sm" id="input-index-name" aria-describedby="nameHelp" placeholder="Enter index name">
</div>
<div class="form-group">
<label class="form-label">Category</label>
<select class="form-control form-control-sm">
<option selected disabled>Select a category</option>
<option>Business and Economy</option>
<option>Communities and Social Services</option>
<option>Government Administration</option>
<option>Nature and Environment</option>
</select>
</div>
<div class="form-group">
<label class="form-label">Dataset</label>
<select class="form-control form-control-sm">
<option selected disabled>Select a dataset</option>
<option>Crime Statistics - Incidents and rates by offence category</option>
<option>Dataset 2</option>
</select>
</div>
<div class="form-group">
<label class="form-label">Variables</label>
<div id="create-variables">
<div class="row form-group">
<div class="col-7">
<select class="form-control form-control-sm">
<option selected disabled>Select a variable</option>
<option>Rate Other Criminal Code</option>
<option>Rate Property Crime</option>
<option>Rate Violent Criminal Code</option>
</select>
</div>
<div class="col-3">
<input class="form-control form-control-sm" value="1" maxlength="2">
</div>
<div class="col-1">
<button class="btn text-muted" style="padding: 0px; padding-top: 2px" onclick="addVariable(this)"><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle">
<path d="M14.613,10c0,0.23-0.188,0.419-0.419,0.419H10.42v3.774c0,0.23-0.189,0.42-0.42,0.42s-0.419-0.189-0.419-0.42v-3.774H5.806c-0.23,0-0.419-0.189-0.419-0.419s0.189-0.419,0.419-0.419h3.775V5.806c0-0.23,0.189-0.419,0.419-0.419s0.42,0.189,0.42,0.419v3.775h3.774C14.425,9.581,14.613,9.77,14.613,10 M17.969,10c0,4.401-3.567,7.969-7.969,7.969c-4.402,0-7.969-3.567-7.969-7.969c0-4.402,3.567-7.969,7.969-7.969C14.401,2.031,17.969,5.598,17.969,10 M17.13,10c0-3.932-3.198-7.13-7.13-7.13S2.87,6.068,2.87,10c0,3.933,3.198,7.13,7.13,7.13S17.13,13.933,17.13,10"></path></svg></button>
</div>
</div>
</div>
</div>
<script type="text/javascript">
function addVariable(btn) {
btn.remove('.btn');
$('#create-variables').append(`
<div class="row form-group">
<div class="col-7">
<select class="form-control form-control-sm">
<option selected disabled>Select a variable</option>
<option>Rate Other Criminal Code</option>
<option>Rate Property Crime</option>
<option>Rate Violent Criminal Code</option>
</select>
</div>
<div class="col-3">
<input class="form-control form-control-sm" value="1" maxlength="2">
</div>
<div class="col-1">
<button class="btn text-muted" style="padding: 0px; padding-top: 2px" onclick="addVariable(this)"><svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 28 28" fill="none" stroke="currentColor" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" class="feather feather-plus-circle">
<path d="M14.613,10c0,0.23-0.188,0.419-0.419,0.419H10.42v3.774c0,0.23-0.189,0.42-0.42,0.42s-0.419-0.189-0.419-0.42v-3.774H5.806c-0.23,0-0.419-0.189-0.419-0.419s0.189-0.419,0.419-0.419h3.775V5.806c0-0.23,0.189-0.419,0.419-0.419s0.42,0.189,0.42,0.419v3.775h3.774C14.425,9.581,14.613,9.77,14.613,10 M17.969,10c0,4.401-3.567,7.969-7.969,7.969c-4.402,0-7.969-3.567-7.969-7.969c0-4.402,3.567-7.969,7.969-7.969C14.401,2.031,17.969,5.598,17.969,10 M17.13,10c0-3.932-3.198-7.13-7.13-7.13S2.87,6.068,2.87,10c0,3.933,3.198,7.13,7.13,7.13S17.13,13.933,17.13,10"></path></svg></button>
</div>
</div>`);
}
</script>
<div class="row m-1">
<button class="btn btn-sm btn-outline-secondary" onclick="createIndex(this)">Create</button>
<button class="btn btn-sm btn-outline-secondary" style="margin-left: 15px">Update</button>
</div>
<script type="text/javascript">
function createIndex(obj) {
$('#create-index').collapse('toggle');
$('#select-index').collapse('toggle');
d3.select("#create-alert").classed("show", true);
window.setTimeout(function() {
d3.select("#create-alert").classed("show", false);
}, 3000);
}
</script>
</div>
<div id="create-alert" class="alert alert-success alert-dismissible fade" role="alert">
<strong>Index created!</strong>
<button type="button" class="close" data-dismiss="alert" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
</div>
<div class="col-6" id="main-view">
<div class="p-3">
<div class="row" id="index-label" style="visibility: hidden">
<h3 class="text-dark-menu">Index:</h3> <h3 class="text-dark-menu" id="map-index-name"></h3>
</div>
<div class="row" id="county-label" style="visibility: hidden">
<h4 class="text-dark-menu ">County:</h4> <h4 class="text-dark-menu" id="map-county-name"></h4>
</div>
</div>
<div class="row" style="text-align: center; margin-top: -60px">
<svg id="content" width="100%" height="320px" viewBox="0 0 700 350">
<g>
<g transform="scale(25,25) ">
<g class="map" transform="translate(-300,-124)">
</g>
</g>
<g id="map-legend" transform="translate(380,230)">
</g>
</g>
</svg>
<div id="year-slider" class="col-12 slider-div" hidden>
<p class="slider-header">Year: <span id="selected-year">2010</span></p>
<input id="year-selector" type="range" min="2010" max="2017" value="2010" class="slider" id="myRange" onchange="yearChange(this)">
<script type="text/javascript">
function yearChange(obj) {
const year = obj.value;
d3.select("#selected-year").text(year);
theMap.selectedYear = year;
theMap.indexData[0] = criminality_idx[year];
pieChart("#pie0", theMap.getIndexParamsForCounty(0, 'Halifax'), theMap.getIndexParamNames(0));
updateMap(theMap.indexData[0].data);
}
</script>
</div>
</div>
<div id="piechart-view" class="row" hidden>
<div class="col"></div>
<div class="col">
<h6 id="pie0-text">Index 0</h6>
<svg width="250" height="250">
<g id="pie0" class="pie" index="0"></g>
</svg>
</div>
<div class="col"></div>
<div class="col">
<h6 id="pie1-text">Index 1</h6>
<svg width="250" height="250">
<g id="pie1" class="pie unfocus" index="1">
<text>Index 0</text>
</g>
</svg>
</div>
<div class="col"></div>
</div>
</div>
<div class="col-3" id="right-panel">
<br>
<div id="rank-view" hidden>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center text-muted"><span>Index Ranking</span></h6>
<svg width="260" height="375">
<g id="county-ranking" class="ranking" transform="translate(0, 10)">
</g>
</svg>
<div id="timelapse-div" hidden>
<h6 class="sidebar-heading d-flex justify-content-between align-items-center text-muted"><span>Index Timelapse</span></h6>
<svg width="260" height="165">
<g id="county-timelapse" class="linegraph" transform="translate(0, 10)">
</g>
</svg>
</div>
</div>
</div>
</div>
</main>
</div>
<script src="js/map.js"></script>
</body>
</html>