forked from dong-y/D3.js_tutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_loading_external_data.html
More file actions
53 lines (39 loc) · 963 Bytes
/
10_loading_external_data.html
File metadata and controls
53 lines (39 loc) · 963 Bytes
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
<!doctype html>
<html>
<head>
<title>D3 tutorial</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js"></script>
</head>
<body>
<script>
d3.csv("mydata.csv",
function (data){
//console.log(err);
console.log(data);
//console.log('Here');
var canvas = d3.select("body").append("svg")
.attr("width", 500)
.attr("height", 500)
canvas.selectAll("rect")
.data(data)
.enter()
.append("rect")
.attr("width", function (d) { return d.age * 10 })
.attr("height", 48)
.attr("y", function (d, i) {
return i * 50
})
.attr("fill", "blue");
canvas.selectAll("text")
.data(data)
.enter()
.append("text")
.attr("fill", "white")
.attr("y", function (d, i) {
return i * 50 + 24;})
.text(function (d) {
return d.name +' ' + d.age; })
})
</script>
</body>
</html>