Created
December 2, 2012 08:47
-
-
Save captainwz/4187751 to your computer and use it in GitHub Desktop.
d3-3-demo1
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> | |
<script src="d3-3-demo1-jsondata.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
function show(data){ | |
d3.select("body") | |
.append("ul") | |
.selectAll("li") | |
.data(data.member) | |
.enter() | |
.append("li") | |
.text(function(d){ | |
return d.name+"'s age is "+d.age; | |
}); | |
} | |
</script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
show(data); | |
</script> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var data= | |
{ | |
"flight":815, | |
"member": | |
[{ | |
"name":"Jack", | |
"sex":"male", | |
"age":30 | |
}, | |
{ | |
"name":"Kate", | |
"sex":"female", | |
"age":28 | |
}, | |
{ | |
"name":"Sawyer", | |
"sex":"male", | |
"age":29 | |
}, | |
{ | |
"name":"John", | |
"sex":"male", | |
"age":40 | |
}] | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment