-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
69 lines (61 loc) · 2.43 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Marc Sensenich | All the States</title>
</head>
<body style="margin: 0;">
<header style="box-shadow: 0 -10px 20px 3px #000; top: 0; left: 0; width: 100%; padding: 16px 8px 16px 8px;">
<h1 style="font-family: sans-serif; margin: 0;"><a style="text-decoration: none; color: #000;" href="http://www.marc-sensenich.com">Marc Sensenich's</a> Visited States</h1>
</header>
<svg width="960" height="600" stroke-linejoin="round" stroke-linecap="round">
<defs>
<filter id="blur">
<feGaussianBlur stdDeviation="5"></feGaussianBlur>
</filter>
</defs>
</svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script src="https://d3js.org/topojson.v2.min.js"></script>
<script src="https://d3js.org/d3-queue.v3.min.js"></script>
<script>
var svg = d3.select("svg");
var defs = svg.select("defs");
var path = d3.geoPath();
function drawMap(error, us, stateStatus, config) {
if (error) throw error;
var nation = topojson.feature(us, us.objects.nation);
var states = topojson.feature(us, us.objects.states);
defs.append("path")
.attr("id", "nation")
.attr("d", path(nation));
svg.append("use")
.attr("xlink:href", "#nation")
.attr("fill-opacity", 0.2)
.attr("filter", "url(#blur)");
svg.append("use")
.attr("xlink:href", "#nation")
.attr("fill", "#fff");
svg.selectAll("states")
.data(states.features)
.enter()
.insert("path", ".graticule")
.attr("class", "states")
.attr("d", path)
.attr("fill", function(currentState) { return stateStatus[currentState.id].visited ? config["visitedColor"] : config["unvisitedColor"]; });
svg.append("path")
.attr("fill", "none")
.attr("stroke", config["strokeColor"])
.attr("stroke-width", 0.70)
.attr("d", path(topojson.mesh(us, us.objects.states, function (a, b) { return a !== b; })));
}
d3.queue()
.defer(d3.json, "https://d3js.org/us-10m.v1.json")
.defer(d3.json, "./data/state-status.json")
.defer(d3.json, "./data/config.json")
.await(drawMap)
</script>
</body>
</html>