forked from d3/d3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalt.html
67 lines (58 loc) · 1.56 KB
/
alt.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
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8">
<title>d4</title>
<script type="text/javascript" src="d3.js"></script>
</head>
<body>
<table>
<tr><td><span>0</span></td><td><span>1</span></td></tr>
<tr><td><span>2</span></td><td><span>3</span></td></tr>
</table>
<a href="1">blink 1</a>
<a href="2">blink 2</a>
<a href="3">blink 3</a>
<a href="4">blink 4</a>
<a href="5">blink 5</a>
<a href="6">blink 6</a>
<script type="text/javascript">
var span = d3.selectAll("tr") // [tr, tr]
.selectAll("td") // [[td, td], [td, td]]
.select("span") // [[span, span], [span, span]]
.data([1, 2, 3]);
span.enter("td")
.append("span")
.text(function(d, i) { return d; });
span.remove() // removes spans and selects parent td
.text(function(d, i) { return Math.random(); })
.transition()
.attr("height", 100);
var links = d3.select("body")
.selectAll("a:link")
.data([{href:3}, {href:2}], "href")
.text(function(d) { return d.href; });
links.enter("a")
.attr("href", function(d) { return d.href; })
.text(function(d) { return d.href; });
links.exit()
.transition()
.delay(function(d, i) { return i * 50; })
.each("end", fadein);
function fadein(d, i) {
d3.select(this)
.transition()
.duration(500)
.style("opacity", 1)
.each("end", fadeout);
}
function fadeout(d, i) {
d3.select(this)
.transition()
.duration(500)
.style("opacity", 0)
.each("end", fadein);
}
</script>
</body>
</html>