-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
executable file
·160 lines (140 loc) · 3.55 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
<!DOCTYPE html>
<html>
<head>
<title>US Map Demo</title>
<!-- Ideas and tools used from: -->
<!-- * https://newsignature.github.io/us-map/#about -->
<!-- * http://bl.ocks.org/NPashaP/a74faf20b492ad377312 -->
<style>
#tooltip {
position: absolute;
text-align: center;
padding: 20px;
margin: 10px;
font: 12px sans-serif;
background: lightsteelblue;
border: 1px;
border-radius: 2px;
pointer-events: none;
z-index: 1;
}
#tooltip h4{
margin:0;
font-size:14px;
}
#tooltip {
background:rgba(0,0,0,0.9);
border:1px solid grey;
border-radius:5px;
font-size:12px;
width:auto;
padding:4px;
color:white;
opacity:0;
}
#tooltip table {
table-layout:fixed;
}
#tooltip tr td {
padding:0;
margin:0;
}
#tooltip tr td:nth-child(1) {
width:50px;
}
#tooltip tr td:nth-child(2) {
text-align:center;
}
.stateClicked {
fill: 'teal',
"stroke-width": 2,
opacity: 1
}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="lib/raphael.js"></script>
<script src="lib/jquery.usmap.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.13.0/d3.min.js"></script>
<script>
$(document).ready(function() {
$('#map').usmap({
// Externalized function to create html content string in tooltip div.
'toolTipHtml': function(stateData) {
return "<h4>" + stateData.fullName + "</h4><table>"+
"<tr><td>Low</td><td>" + 'butts1' + "</td></tr>"+
"<tr><td>Average</td><td>" + 'butts2' + "</td></tr>"+
"<tr><td>High</td><td>" + 'butts3' + "</td></tr>"+
"</table>";
},
// State default styles
'stateStyles': {
fill: '#cccccc',
"stroke-width": 0,
'stroke' : '#fff',
opacity: 1
},
// State hover styles
'stateHoverStyles': {
fill: 'teal',
"stroke-width": 2,
opacity: 0.5
},
// Make DC hover outline teal, otherwise it just turns all white
'stateSpecificHoverStyles': {
'DC': {'stroke': 'teal'}
},
// Northeast state labels (like 'NJ', 'CT', 'RD', etc.) default styles
'labelBackingStyles': {
fill: '#c0c0c0',
"stroke-width": 0,
'stroke' : '#fff',
opacity: 1
},
// State labels default radius style (rounded corners looks bad)
'labelRadius': 0,
// State labels default text styles
'labelTextStyles': {
'font-weight': 600,
'font-size': 10,
'fill': '#fff'
},
// State labels default hover styles
'labelBackingHoverStyles': {
"stroke-width": 1,
'fill': 'teal',
opacity: 0.6
},
// CUSTOM - Add click styles
'stateClickStyles': {
fill: 'teal',
"stroke-width": 3,
opacity: 1
},
// CUSTOM - Allow a specific style for DC
'stateSpecificClickStyles': {
'DC': {'stroke': 'teal'}
},
// CUSTOM - Add click styles for labels too
'labelBackingClickStyles': {
"stroke-width": 1,
'fill': 'teal',
opacity: 1
},
// How long it takes for the hover-color to fade in (msecs)
'stateHoverAnimation': 100,
// What to do on a click event
'click' : function(event, data) {
$('#clicked-state').text('Clicked '+data.fullName+' on map');
},
});
});
</script>
</head>
<body>
<div>
<div id="clicked-state">Nothing clicked yet</div>
</div>
<div id="tooltip"></div>
<div id="map" style="width: 1000px; height: 630px; border: solid 3px teal"></div>
</body>
</html>