-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
3207 lines (2822 loc) · 123 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
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!--- Code For Website Starts Here -->
<!DOCTYPE html>
<html lang="en">
<!--- Start of HEAD -->
<head>
<!-- All Meta links -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<!-- The Javascript from external websites -->
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<!-- All lunks and Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="style.css" rel="stylesheet">
<!-- Map Styling Within Head -->
<style>
#wrapper {
height: 100% width: 100%;
position: relative;
}
#map-canvas {
height: 830px;
width: 55%;
margin-bottom: 10px;
margin-left: 5%;
margin-right: 160px;
margin-top: 30px;
padding: 40px;
position: absolute;
}
#controls {
top: 80px;
left: 110px;
width: 360px;
height: 65px;
}
#data-box {
margin-top: 40px;
height: 45px;
line-height: 45px;
display: none;
margin-left: 40%;
position: absolute;
z-index: 1;
}
#census-variable {
width: 360px;
height: 20px;
}
#legend {
display: flex;
display: -webkit-box;
padding-top: 7px;
margin-left: : 60%;
width: 25%
}
.color-key {
background: linear-gradient(to right,
hsl(30, 100%, 99%) 0%,
hsl(24, 100%, 76%) 70%,
hsl(1, 57%, 57%) 100%);
flex: 1;
-webkit-box-flex: 1;
margin: 0 160px;
text-align: center;
font-size: 1.0em;
line-height: 1.0em;
width: 280px;
position: absolute;
margin-left: 40%;
margin-top: 80px;
}
.census-min {
margin-left: : 120px;
}
.census-max {
margin-left: 120px;
}
#data-value {
font-size: 1.5em;
font-weight: bold;
text-align: left
}
#data-label {
font-size: 1.5em;
font-weight: normal;
margin: text-align: left
}
#data-label: after {
content: ':'
}
#data-caret {
margin-left: -5px;
display: none;
font-size: 25px;
width: 10px
}
</style>
<!--- END of HEAD -->
</head>
<!--- Start Of Body -->
<body onload="document.getElementById(" census-variable small").dataManage();">
<!-- NAVBAR -->
<nav class=" navbar navbar-inverse navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a class="navbar-brand" href="#" onclick="smoothScroll(document.getElementById('about'))"> Chicago's Gun
Violence </a>
</div>
<ul class="nav navbar-nav">
<li><a href="#" onclick="smoothScroll(document.getElementById('mapid'))">Map & Analysis</a></li>
<li><a href="#" onclick="smoothScroll(document.getElementById('methods'))">Overview </a></li>
<li><a href="#" onclick="smoothScroll(document.getElementById('read'))"> Methodology & Data </a></li>
<li><a href="#" onclick="smoothScroll(document.getElementById('aut'))"> The Authors </a></li>
</ul>
</div>
</nav>
<!-- FRONT PAGE -->
<div class="container" id="about">
<h1 class="page-header text-center" ,"text-center">Chicago's Gun Violence </h1>
<p class="lead">
The following visualisation will compare the location of gun shootings within Chicago's communities with
socio-economic variables.
Mapping out the precise location of gun violence alongside different factors shows significant spatial
variation in where these events occur.
The tool allows a user to click on a variable to obtain a statistical analysis of how gun shootings compare
across Chicago's community areas.
<p class=" lead1 lead" ,"text-center">- Click on the variable buttons, to see an updated chloropleth map,
linear regression and analysis.<br>
- Hover over specific communities, to analyse how they differ with other communities within Chicago.<br>
- Click on specific incidents, to explore the date of the event and how many where injured/killed. <br>
- Click on clusters to see an analysis of similarities between communities. </p>
</div>
<div class="container">
<div class="btn">
<button type="button" class=" btn1 btn-default btn-lg"
onclick="smoothScroll(document.getElementById('mapid'))">Go To The Map</button>
<button type="button" class="btn2 btn-default btn-lg"
onclick="smoothScroll(document.getElementById('methods'))">Read More</button>
</div>
<div class="mapster" id="mapid">
<h2 class="page-header1 page-header text-center" ,"text-center"> Map & Analysis </h2>
<div class="container">
<h5 class="mapdescription page-header1 lead text-center" ,"text-center">
<h5 class="mapdescription lead" ,"text-center"> Select variable of interest, explore the map and
statistical analysis on the right hand side. </h5>
</h5>
</div>
<div class="btn">
<!-- Incident Rate Action Button -->
<button type="button" class="btn3 btn-default link " id="census-variable small1" href="#about"
data-link="eigth" onclick="dataManage(0)" value=7> Incident Rate</button>
<!-- Per Capita Income Action Button -->
<button type="button" class="btn3 btn-default link " id="census-variable small" href="#about"
data-link="third" onclick="dataManage(7)" value=7>Per Capita Income</button>
<!-- Housing Vavancy Action Button -->
<button type="button" class="btn3 btn-default link" id="census-variable small" href="#about"
data-link="first" onclick="dataManage(3)" value=3>Housing Vacancy Rate</button>
<!-- School Dropout Rate Action Button -->
<button type="button" class=" btn3 btn-default link" href="#about" data-link="second"" onclick="
dataManage(4)" value=4 id="census-variable small ">School Dropout Rate</button>
<!-- Family Structure Action Button -->
<button type="button" class="btn3 btn-default link" href="#about" data-link="fourth"" onclick="
dataManage(5)" value=5 id="census-variable small">Family Structure</button>
<!-- Age of Home -->
<button type="button" class="btn3 btn-default link " href="#about" data-link="fifth"" id="
census-variable small" onclick="dataManage(6)" value=6>Age of Housing</button>
<!-- Mental Health -->
<button type="button" class="btn3 btn-default link " href="#about" data-link="sixth"" id="
census-variable small" onclick="dataManage(1)" value=1>Mental Health</button>
<!-- Type of occupancy -->
<button type="button" class=" btn3 btn-default link " href="#about" data-link="seventh"" id="
census-variable small" onclick="dataManage(2)" value=2>Occupied Housing Rented Rate</button>
<!-- Clustering -->
<button type="button" class="btn3 btn-default link " onclick="dataManage(8)" href="#about"
data-link="ninth"" id=" census-variable small">Clusters</button>
</div>
</div>
</div>
<div id="wrapper">
<div id="legend"></div>
<div> </div>
<div> </div>
<div id="data-box" class="nicebox">
<label id="data-label" for="data-value"></label>
<span id="data-value"></span>
</div>
<div id='map-canvas'>
</div>
<div class="color-key"><span id="data-caret">◆</span></div>
<!-- The Javascript from external websites gets Loaded Here -->
<script type='text/javascript' src='http://code.jquery.com/jquery-1.10.2.min.js?ver=1.10.2'></script>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?libraries=visualization&sensor=true"> </script>
<script type='text/javascript' src='http://arshaw.com/xdate/downloads/0.8/xdate.js'></script>
<script type='text/javascript' src='mapStyle.js'></script>
<!-- The Javascript gets loaded here -->
<script type="text/javascript">
var map;
var markerArray = [];
var dataArray = [];
var infowindow = new google.maps.InfoWindow({ maxWidth: 300 });
var censusMin = Number.MAX_VALUE, censusMax = -Number.MAX_VALUE;
var mapStyle = [
{
"elementType": "geometry",
"stylers": [
{
"color": "#f5f5f5"
}
]
},
{
"elementType": "labels.icon",
"stylers": [
{
"visibility": "off"
}
]
},
{
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#616161"
}
]
},
{
"elementType": "labels.text.stroke",
"stylers": [
{
"color": "#f5f5f5"
}
]
},
{
"featureType": "administrative.land_parcel",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "administrative.land_parcel",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#bdbdbd"
}
]
},
{
"featureType": "administrative.neighborhood",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi",
"elementType": "geometry",
"stylers": [
{
"color": "#eeeeee"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "poi",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#757575"
}
]
},
{
"featureType": "poi.park",
"elementType": "geometry",
"stylers": [
{
"color": "#e5e5e5"
}
]
},
{
"featureType": "poi.park",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
},
{
"featureType": "road",
"elementType": "geometry",
"stylers": [
{
"color": "#ffffff"
}
]
},
{
"featureType": "road",
"elementType": "labels",
"stylers": [
{
"visibility": "on"
}
]
},
{
"featureType": "road.arterial",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#757575"
}
]
},
{
"featureType": "road.highway",
"elementType": "geometry",
"stylers": [
{
"color": "#dadada"
}
]
},
{
"featureType": "road.highway",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#616161"
}
]
},
{
"featureType": "road.local",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
},
{
"featureType": "transit.line",
"elementType": "geometry",
"stylers": [
{
"color": "#e5e5e5"
}
]
},
{
"featureType": "transit.station",
"elementType": "geometry",
"stylers": [
{
"color": "#eeeeee"
}
]
},
{
"featureType": "water",
"elementType": "geometry",
"stylers": [
{
"color": "#c9c9c9"
}
]
},
{
"featureType": "water",
"elementType": "labels.text",
"stylers": [
{
"visibility": "off"
}
]
},
{
"featureType": "water",
"elementType": "labels.text.fill",
"stylers": [
{
"color": "#9e9e9e"
}
]
}
];
function initialize() {
var mapOptions = {
center: new google.maps.LatLng(41.78, -87.66),
zoom: 11,
styles: mapStyle,
rotateControl: true,
scrollwheel: false
};
map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
var zoom = map.getZoom();
if (zoom < 14) {
map.data.setStyle(styleFeature);
map.data.addListener('mouseover', mouseInToRegion);
map.data.addListener('mouseout', mouseOutOfRegion);
}
else if (zoom >= 14) {
map.data.setStyle(styleFeature1);
map.data.addListener('mouseover', mouseInToRegion1);
map.data.addListener('mouseout', mouseOutOfRegion1);
};
getIncidentData();
loadMapShapes();
document.getElementById("census-variable small1").click();
}
function dataManage(i) {
clearVariableData();
var zoom = map.getZoom();
if (zoom < 14) {
loadCommunityData(i);
}
else if (zoom >= 14) {
loadTractData(i);
}
}
function getIncidentData() {
console.log("Getting Data: Incidents");
setAllMap(null);
markerArray = [];
$.getJSON("http://dev.spatialdatacapture.org:8890/data/incidents", function (data) {
$.each(data, function (k, v) {
var latLng = new google.maps.LatLng(v.latitude, v.longitude);
dataArray.push(latLng);
var marker = new google.maps.Marker({
position: latLng,
icon: "./img/icon.png",
customInfo: v.gva_id
});
marker.addListener('click', function (content) {
return function () {
infowindow.setContent("");
var content = "<b>Date: </b>" + v.incident_d + "<br/><b>Number Killed:</b>" + v.num_killed + "<br/><b>Number Injured:</b>" + v.num_injure + "<br/><b>For more information: </b><br/>http://www.gunviolencearchive.org/incident/" + v.gva_id;
infowindow.setContent(content);
infowindow.open(map, this);
}
}(""));
markerArray.push(marker);
});
$("#photoNum").html(data.length);
setAllMap(map);
});
}
google.maps.event.addDomListener(window, 'load', initialize);
//load variable data
function loadTractData(i) {
console.log("Getting Data: Tracts");
console.log(i);
// load the requested variable from the census API (using local copies)
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://dev.spatialdatacapture.org:8890/data/tracts');
xhr.responseType = 'json';
xhr.onload = function () {
var censusData = xhr.response;
console.log(censusData);
//censusData.shift(); // the first row contains column names
$(jQuery.parseJSON(JSON.stringify(censusData))).each(function () {
var id = this.geojoin;
var variableArray = [];
variableArray[0] = Math.round(this.incidentrate * 100) / 100;
variableArray[1] = (this.MentalHealthValue) / 100;
variableArray[2] = Math.round(this.pctrented * 100) / 100;
variableArray[3] = Math.round(this.pctvacant * 100) / 100;
variableArray[4] = Math.round(this.pctnohsd * 100) / 100;
variableArray[5] = Math.round(this.pctchildinmf * 100) / 100;
variableArray[6] = this.medianyearbuilt;
variableArray[7] = this.percapitaincome;
variableArray[8] = this.stid;
var censusVariable = variableArray[i];
// keep track of min and max values
if (censusVariable < censusMin) {
censusMin = censusVariable;
}
if (censusVariable > censusMax) {
censusMax = censusVariable;
}
// update the existing row with the new data
map.data
.getFeatureById(id)
.setProperty('census_variable', censusVariable);
});
};
xhr.send();
}
function loadCommunityData(i) {
console.log("Getting Data: Communities");
console.log(i);
// load the requested variable from the census API (using local copies)
var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://dev.spatialdatacapture.org:8890/data/communities');
xhr.responseType = 'json';
xhr.onload = function () {
var censusData = xhr.response;
console.log(censusData);
//censusData.shift(); // the first row contains column names
$(jQuery.parseJSON(JSON.stringify(censusData))).each(function () {
var id = this.COMMAREA;
var variableArray = [];
variableArray[0] = Math.round(this.incident_rate * 100) / 100;
variableArray[1] = Math.round(this.MentalHealthValue * 100) / 100;
variableArray[2] = Math.round(this.Renter_Occupied_rate * 100) / 100;
variableArray[3] = Math.round(this.Vacant_rate * 100) / 100;
variableArray[4] = Math.round(this.lessthanhsd_rate * 100) / 100;
variableArray[5] = Math.round(this.marriedWithChildren * 100) / 100;
variableArray[6] = Math.round(this.medianyearbuilt);
variableArray[7] = Math.round(this.percapitaincome);
variableArray[8] = this.stid;
var censusVariable = variableArray[i]
console.log(censusVariable);
// keep track of min and max values
if (censusVariable < censusMin) {
censusMin = censusVariable;
}
if (censusVariable > censusMax) {
censusMax = censusVariable;
}
// update the existing row with the new data
map.data
.getFeatureById(id)
.setProperty('census_variable', censusVariable);
});
};
xhr.send();
}
function clearVariableData() {
censusMin = Number.MAX_VALUE;
censusMax = -Number.MAX_VALUE;
map.data.forEach(function (row) {
row.setProperty('census_variable', undefined);
});
document.getElementById('data-box').style.display = 'none';
document.getElementById('data-caret').style.display = 'none';
}
//load boundaries
function loadMapShapes() {
map.data.loadGeoJson('http://dev.spatialdatacapture.org:8890/data/communities/boundaries.js', { idPropertyName: 'area_numbe' });
map.data.loadGeoJson('http://dev.spatialdatacapture.org:8890/data/tracts/boundaries.js', { idPropertyName: 'geoid10' });
google.maps.event.addListenerOnce(map.data, 'addfeature', function () {
google.maps.event.trigger(document.getElementById('census-variable small'),
'change');
google.maps.event.trigger(document.getElementById('data-label'),
'change');
});
}
function styleFeature1(feature) {
var low = [5, 69, 54]; // color of smallest datum
var high = [151, 150, 150]; // color of largest datum
// delta represents where the value sits between the min and max
var delta = (feature.getProperty('census_variable') - censusMin) /
(censusMax - censusMin);
var color = [];
for (var i = 0; i < 3; i++) {
// calculate an integer color based on the delta
color[i] = (high[i]) * 0.3 * (1 - delta) + low[i];
}
// determine whether to show this shape or not
var showRow = true;
if (feature.getProperty('census_variable') == null ||
isNaN(feature.getProperty('census_variable'))) {
showRow = false;
}
var outlineWeight = 0.2, zIndex = 1;
if (feature.getProperty('geojoin') === 'hover') {
outlineWeight = 2, zIndex = 1
}
return {
strokeWeight: outlineWeight,
strokeColor: '#4d4f4f',
zIndex: zIndex,
fillColor: 'hsl(' + color[0] + ',' + color[1] + '%,' + color[2] + '%)',
fillOpacity: 0.1,
visible: showRow
};
}
function styleFeature(feature) {
var low = [5, 69, 54]; // color of smallest datum
var high = [151, 150, 150]; // color of largest datum
// delta represents where the value sits between the min and max
var delta = (feature.getProperty('census_variable') - censusMin) /
(censusMax - censusMin);
var color = [];
for (var i = 0; i < 3; i++) {
// calculate an integer color based on the delta
color[i] = (high[i]) * 0.3 * (1 - delta) + low[i];
}
// determine whether to show this shape or not
var showRow = true;
if (feature.getProperty('census_variable') == null ||
isNaN(feature.getProperty('census_variable'))) {
showRow = false;
}
var outlineWeight = 0.2, zIndex = 1;
if (feature.getProperty('COMMAREA') === 'hover') {
outlineWeight = 2, zIndex = 1;
}
return {
strokeWeight: outlineWeight,
strokeColor: '#000000',
zIndex: zIndex,
fillColor: 'hsl(' + color[0] + ',' + color[1] + '%,' + color[2] + '%)',
fillOpacity: 0.5,
visible: showRow
};
}
// ******************* FUNCTIONS TO USE FOR THE MAP YOU DON"T NEED TO EDIT ANYTHING BELOW THIS LINE **************************************************
function createMarkers() {
var marker = new google.maps.Marker({
position: latLng
});
}
function setAllMap(map) {
for (var i = 0; i < markerArray.length; i++) {
markerArray[i].setMap(map);
}
}
function clearMarkers() {
setAllMarkers(null);
}
String.prototype.replaceAll = function (str1, str2, ignore) {
return decodeURIComponent(this.replace(new RegExp(str1.replace(/([\/\,\!\\\^\$\{\}\[\]\(\)\.\*\+\?\|\<\>\-\&])/g, "\\$&"), (ignore ? "gi" : "g")), (typeof (str2) == "string") ? str2.replace(/\$/g, "$$$$") : str2));
}
function mouseInToRegion(e) {
// set the hover state so the setStyle function can change the border
e.feature.setProperty('COMMAREA', 'hover');
var percent = (e.feature.getProperty('census_variable') - censusMin) /
(censusMax - censusMin) * 100;
// update the label
document.getElementById('data-label').textContent =
e.feature.getProperty('community');
document.getElementById('data-value').textContent =
e.feature.getProperty('census_variable').toLocaleString();
document.getElementById('data-box').style.display = 'block';
document.getElementById('data-caret').style.display = 'block';
document.getElementById('data-caret').style.paddingLeft = percent + '%';
}
function mouseInToRegion1(e) {
// set the hover state so the setStyle function can change the border
e.feature.setProperty('geojoin', 'hover');
var percent = (e.feature.getProperty('census_variable') - censusMin) /
(censusMax - censusMin) * 100;
// update the label
document.getElementById('data-label').textContent =
e.feature.getProperty('geoid10');
document.getElementById('data-value').textContent =
e.feature.getProperty('census_variable').toLocaleString();
document.getElementById('data-box').style.display = 'block';
document.getElementById('data-caret').style.display = 'block';
document.getElementById('data-caret').style.paddingLeft = percent + '%';
}
/**
* Responds to the mouse-out event on a map shape (state).
*
* @param {?google.maps.MouseEvent} e
*/
function mouseOutOfRegion(e) {
// reset the hover state, returning the border to normal
e.feature.setProperty('COMMAREA', 'normal');
}
function mouseOutOfRegion1(e) {
// reset the hover state, returning the border to normal
e.feature.setProperty('geojoin', 'normal');
}
</script>
<div id="vacancy" class="textWord_about " data-link="first"
style=" width: 35%; height: 450px; margin-left: 60%; margin-top: 30px ;position:absolute; "></div>
<div style="height:380px;width:35%;border:1px solid grey ;overflow:auto; margin-top: 479px; margin-left: 60%; text-align:center;position:relative;"
class="textWord_about1 lead mapdescription" data-link="first">
<p><b>Results & Description</b></p>
<hr>
<div text align="left">
<p>This variable pays attention to the level of occupation in the built environment defined as the level
of vacant housing units over the total number of housing units. A high vacancy rate may be
associated with either an undesirable neighbourhood where housing is difficult to find occupiers or
high turnover areas that are vacant at time of survey.The map shows gun incidents cluster where
vacancy rate is high, except in downtown. Vacancy rates tend to be high in the South Side and around
Austin where many incidents occur.
The R-value indicates this is the strongest predictor of incidents in our variables, at 0.761. We
can not say whether higher violence causes higher vacancy or vice versa, but that they are related
literature that supports vacancy being a measure of social decline.
</p>
<hr>
</div>
<table style="width:100%">
<tr style="background-color: #B0B0B0">
<th>Line Slope</th>
<th>Intercept</th>
<th>P-Value</th>
<th>Standard Error</th>
<th>R-Value</th>
</tr>
<tr>
<td>224.374</td>
<td>-13.803</td>
<td>9.845e-16</td>
<td>22.098</td>
<td>0.761</td>
</tr>
</table>
</div>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<script type="text/javascript">
Highcharts.chart('vacancy', {
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Housing Vacancy Rate Vs Gun Incidents'
},
subtitle: {
text: 'Source: NHGIS, 2015'
},
xAxis: {
title: {
enabled: true,
text: 'Housing vacancy rate in Chicago`s communities'
},
startOnTick: true,
endOnTick: true,
showLastLabel: true
},
yAxis: {
title: {
text: 'Gun crime incident rate in Chicago`s communities'
}
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 100,
y: 70,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
borderWidth: 1
},
plotOptions: {
scatter: {
marker: {
radius: 4,
states: {
hover: {
enabled: true,
lineColor: 'rgb(112, 128, 144)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x} , {point.y} '
}
}
},
series: [{
name: 'Chicago Community',
color: 'rgba(243, 83, 83, .5)',
data: [[1.35800000e-01, 1.09108000e+01],
[1.24500000e-01, 2.78000000e+00],
[9.64000000e-02, 1.24197000e+01],
[6.88000000e-02, 2.53200000e+00],
[1.03300000e-01, 0.00000000e+00],
[8.72000000e-02, 1.05960000e+00],
[8.72000000e-02, 1.55960000e+00],
[1.53800000e-01, 1.24240000e+00],
[8.44000000e-02, 0.00000000e+00],
[8.23000000e-02, 0.00000000e+00],
[7.46000000e-02, 3.92950000e+00],
[6.96000000e-02, 0.00000000e+00],
[7.61000000e-02, 0.00000000e+00],
[9.44000000e-02, 5.82040000e+00],
[8.85000000e-02, 3.11890000e+00],
[9.69000000e-02, 7.49630000e+00],
[6.39000000e-02, 0.00000000e+00],
[1.16400000e-01, 0.00000000e+00],
[1.03000000e-01, 7.61970000e+00],
[9.58000000e-02, 0.00000000e+00],