-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking.js
63 lines (49 loc) · 1.7 KB
/
working.js
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
<!DOCTYPE html>
<meta charset="utf-8">
<style>
/* CSS goes here. */
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="http://d3js.org/topojson.v1.min.js"></script>
<script>
var width = 500,
height = 750;
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
d3.json("http://localhost:8000/CTA_New.json", function(error, lines) {
if (error) return console.error(error);
console.log(lines);
var projection = d3.geo.mercator()
.center([-87.62946739887555,41.88546497323761])
.scale(90000)
.translate([width - 50,height - 330]);
var path = d3.geo.path()
.projection(projection);
svg.append("path")
.datum(lines)
.attr("d", path)
.attr("fill", 'none')
.attr("stroke","black");
d3.json("http://localhost:8000/Trains_JSON.json", function(error, trains) {
console.log(trains[1].length)
svg.selectAll("circle")
.data(trains)
.enter().append("g")
.each(function(data,i){
d3.select(this).selectAll('circle')
.data(data)
.enter().append('circle')
.transition() // <------- TRANSITION STARTS HERE --------
.delay(function(d,i){ return 1000*i; })
.attr("cx", function(d){return projection([d.lon,d.lat])[0]})
.attr("cy", function(d){return projection([d.lon,d.lat])[1]})
.attr("r", 5)
.style("fill", "red");
})
});
});
//Loop through each minute
// For each minute, display each circle and remove previous set of circles
</script>