Created
December 4, 2012 08:44
-
-
Save captainwz/4201904 to your computer and use it in GitHub Desktop.
d3-6-demo1
This file contains 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-5-demo1.js" type="text/javascript"></script> | |
<script type="text/javascript"> | |
function show(data){ | |
d3.select("body") | |
.append("svg") | |
.attr("width",300) | |
.attr("height",300) | |
.selectAll("circle") | |
.data(data.member) | |
.enter() | |
.append("circle"); | |
var x_scale = d3.scale.linear() | |
.range([60,280]) | |
.domain([20,50]); | |
var y_scale = d3.scale.linear() | |
.range([280,20]) | |
.domain([160,190]); | |
d3.selectAll("circle") | |
.attr("cx",function(d){return x_scale(d.age)}) | |
.attr("cy",function(d){return y_scale(d.height)}) | |
.attr("r",5); | |
var x_axis=d3.svg.axis().scale(x_scale); | |
d3.select("svg") | |
.append("g") | |
.attr("class","x__axis") | |
.attr("transform","translate(0,280)") | |
.call(x_axis); | |
var y_axis=d3.svg.axis().scale(y_scale).orient("left"); | |
d3.select("svg") | |
.append("g") | |
.attr("class","y__axis") | |
.attr("transform","translate(50,0)") | |
.call(y_axis) | |
} | |
</script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
show(data); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment