-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy path7.html
55 lines (54 loc) · 1.83 KB
/
7.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
<!doctype html>
<html>
<head>
<title>D3 tutorial</title>
<!--[if lte IE 8]><script src="r2d3.min.js" charset="utf-8"></script><![endif]-->
<!--[if gte IE 9]><!-->
<script src="http://d3js.org/d3.v3.min.js"></script>
<!--<![endif]-->
<script src="https://google-code-prettify.googlecode.com/svn/loader/prettify.js"></script>
<link href="https://google-code-prettify.googlecode.com/svn/loader/prettify.css" type="text/css" rel="stylesheet" />
</head>
<h3>Enter, Update, Exit</h3>
<a href="index.html">Back to table of contents</a>
<body onload="prettyPrint()">
<pre class="prettyprint">
var data = [10];
var width = 500;
var height = 500;
var canvas = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height);
// Enter example. (more data elements than existing circle elements)
// DOM elements < data elements (enter)
// at this point there's no dom elements for circle yet.
var circle = canvas.selectAll("circle")
// bind empty selections to data
.data(data)
//
.enter()
// append a circle to each data element
.append("circle")
.attr("cx", 50)
.attr("cy", 50)
.attr("r", 25);
</pre>
<script>
var data = [10];
var width = 500;
var height = 500;
var canvas = d3.select("body")
.append("svg")
.attr("width", width)
.attr("height", height);
var circle = canvas.selectAll("circle")
.data(data)
.enter()
.append("circle")
.attr("cx", 50)
.attr("cy", 50)
.attr("r", 25);
</script>
</body>
</html>