-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
132 lines (124 loc) · 3.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
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8"/>
<link rel="stylesheet" type="text/css" href="style.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.3/d3.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/topojson/1.6.9/topojson.min.js"></script>
<script src="datamaps.world.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<div id="container" style="position: relative; width: 1920px; height: 1500px;"></div>
<script>
$(document).ready(function() {
$.ajax({
type: "GET",
url: "csv/ne_dec_c.csv",
dataType: "text",
success: function(data) {processData(data);}
});
});
var bombMap = new Datamap({
element: document.getElementById('container'),
scope: 'world',
projection: 'mercator',
geographyConfig: {
popupOnHover: false,
highlightOnHover: true,
borderColor: '#656578'
},
fills: {
'1-2': '#ffffcc',
'3-8': '#ffeda0',
'9-18': '#fed976',
'19-28': '#fc4e2a',
'29-43': '#e61914',
'44-66': '#b81410',
'67-91': '#8a0f0c',
'92-123': '#bd0026',
'124-363': '#800026',
'364+': '#2e0504',
defaultFill: '#23233f'
},
bubblesConfig: {
borderWidth: 0,
borderOpacity: 1,
borderColor: '#FFFFFF',
popupOnHover: true, // True to show the popup while hovering
radius: null,
popupTemplate: function(geography, data) { // This function should just return a string
return '<div class="hoverinfo"><strong>' + data.fillKey + '</strong></div>';
},
animate: true,
highlightOnHover: true,
}
});
bombMap.legend();
var bombs = [];
var fills = ['1-2', '3-8', '9-18', '19-28', '29-43', '44-66', '67-91', '92-123', '124-363', '364+'];
function colorFromLag(lag) {
if(lag < 3)
return 0;
else if (lag < 9)
return 1;
else if (lag < 19)
return 2;
else if (lag < 29) //dark orange
return 3;
else if (lag < 44) //red
return 4;
else if (lag < 67)
return 5;
else if (lag < 92)
return 6;
else if (lag < 124)
return 7;
else if (lag < 364)
return 8;
else
return 9;
}
function processData(allText) {
var allTextLines = allText.split(/\r\n|\n/);
var headers = allTextLines[0].split(',');
var lines = [];
for (var i=1; i<allTextLines.length; i++) {
var data = allTextLines[i].split(',');
if (data.length == headers.length) {
var tarr = [];
for (var j=0; j<headers.length; j++) {
tarr.push(data[j]);
}
bombs.push({
radius: 5,
fillOpacity: 1,
fillKey: fills[colorFromLag(tarr[2])],
latitude: tarr[0],
longitude: tarr[1]
});
//shine
/*
bombs.push({
radius: 2,
fillOpacity: .7,
fillKey: fills[colorFromLag(tarr[2])],
latitude: tarr[0],
longitude: tarr[1]
});
bombs.push({
radius: 4,
fillOpacity: .5,
fillKey: fills[colorFromLag(tarr[2])],
latitude: tarr[0],
longitude: tarr[1]
});
*/
}
}
bombMap.bubbles(bombs, {});
}
//draw bubbles for bombs
//bombMap.bubbles(bombs, {});
//bombMap.bubbles(bombs, {});
</script>
</head>
</html>