-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcodelitt-team.html
82 lines (72 loc) · 2.84 KB
/
codelitt-team.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Codelitt Team</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.16/d3.min.js"></script>
<script src="http://d3js.org/topojson.v0.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<div id="content">
<div class="viz"></div>
<div id="about">
<p class"about-text">A little bit about this visualization:</p>
<p>This is a geo-representation of where Codelitt Incubator is represented around the world and a testimony to our diversity. The larger a circle is, the more people in that particular city.</p>
<h3><a href="/">< Back</a></h3>
</div>
</div>
<script type="text/javascript">
//Sizing
var w = parseInt(d3.select('#content').style('width'));
var h = 500;
var margin = 50;
//Create projection:
var projection = d3.geo.mercator();
//Create SVG
var svg = d3.select(".viz")
.append("svg")
.attr("width", w)
.attr("height", h);
var path = d3.geo.path()
.projection(projection);
var g = svg.append("g");
//Draws countries
d3.json("world-110m2.json", function(error, topology) {
g.selectAll("path")
.data(topojson.object(topology, topology.objects.countries).geometries)
.enter()
.append("path")
.attr("d", path)
.attr("fill", "#ADD8E6")
.attr("stroke", "#FFF");
});
d3.csv("codelitt-team.csv", function(dataset) {
//Creates a nested set of data and provides the count per city which is most important
var countByCity = d3.nest()
.key(function(d) { return d.city; })
.rollup(function(v) { return {
count: v.length,
//TODO: Don't use max. Should be some sort of map, but I'm lazy now.
latitude: d3.max(v, function(d) { return d.latitude }),
longitude: d3.max(v, function(d) { return d.longitude }),
locationTo: v.map(function(d) { return d.city + "," + d.state + "," + d.country })
}; })
.entries(dataset);
//Circle for each person
svg.selectAll("circle")
.data(countByCity)
.enter()
.append("circle")
.attr("fill", "green")
.attr("opacity", .5)
.attr("r", function(d) { return 5 * d.values.count })
.attr("transform", function(d) {return "translate(" + projection([d.values.longitude,d.values.latitude]) + ")";})
.attr("stroke", "#fff")
.append("svg:title")
.text(function(d) { return d.values.locationTo[0]; });
});
</script>
</body>
</html>