forked from markmarkoh/datamaps
-
Notifications
You must be signed in to change notification settings - Fork 0
/
custom-labels.html
88 lines (86 loc) · 2.31 KB
/
custom-labels.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Custome Labels</title>
<script src="http://d3js.org/d3.v3.min.js"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script src="/src/rel/datamaps.usa.js"></script>
</head>
<body>
<h1>Custom Labels</h1>
<div id="container1" style="position: relative; width: 800px; height: 600px;"></div>
<script>
var USdata = {
'AK': 'Alaska',
'AL': '123',
'AR': '7576',
'AZ': '345',
'CA': '453',
'CO': '453',
'CT': '765',
'DC': '234',
'DE': '35434',
//'FL': 'Florida', Simulate a missing value defaults to 2 letter abbr
'GA': '',
'HI': '234',
'IA': '234',
'ID': 'Idaho',
'IL': '234',
'IN': '234',
'KS': '234',
'KY': '234',
'LA': '234',
'MA': '234',
'MD': '7566',
'ME': '567',
'MI': '567',
'MN': '46',
'MO': '456',
'MS': '567',
'MT': '345',
'NC': '456',
'ND': '345',
'NE': '65',
'NH': '356',
'NJ': '54',
'NM': '4356',
'NV': '5463',
'NY': '3456',
'OH': '2345',
'OK': '2345',
'OR': '564',
'PA': '456',
'RI': '234',
'SC': '234',
'SD': '5467',
'TN': '5467',
'TX': '2345',
'UT': '345',
'VA': '432',
'VT': '654',
'WA': '456',
'WI': '543',
'WV': '345',
'WY': '1234'};
var USmap = new Datamap({
element: document.getElementById("container1"),
scope: 'usa', //currently supports 'usa' and 'world', however with custom map data you can specify your own
projection: 'equirectangular', //style of projection to be used. try "mercator"
height: 520, //if not null, datamaps will grab the height of 'element'
fills: {
defaultFill: '#EDDC4E'
},
geographyConfig: {
highlightBorderColor: '#bada55',
popupTemplate: function (geography, data) {
return '<div class="hoverinfo">' + geography.properties.name + '</div>';
},
highlightBorderWidth: 2
}
});
USmap.labels({'customLabelText': USdata});
</script>
</div>
</body>
</html>