Created
July 20, 2013 06:24
-
-
Save roippi/6044065 to your computer and use it in GitHub Desktop.
embedded circles...
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
<!DOCTYPE html> | |
<style> | |
.outer { | |
fill: yellow; | |
stroke: steelblue; | |
stroke-width: 1px; | |
} | |
.inner { | |
fill: orange; | |
} | |
</style> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>D3 Test</title> | |
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script> | |
</head> | |
<body> | |
<script type="text/javascript"> | |
var h = 50; | |
var w = 500; | |
var svg = d3.selectAll("body").append("svg") | |
.attr("width", w) | |
.attr("height",h); | |
var dataset = [ 5, 10, 15, 20, 25 ]; | |
var containers = svg.selectAll("g") | |
.data(dataset); | |
var outer = containers | |
.enter() | |
.append("circle") | |
.attr("class","outer"); | |
var inner = containers | |
.enter() | |
.append("circle") | |
.attr("class","inner"); | |
outer.attr("cx", function(d, i) { | |
return (i * 50) + 25; | |
}) | |
.attr("cy", h/2) | |
.attr("r", function(d) { | |
return d; | |
}); | |
inner.attr("cx", function(d, i) { | |
return (i * 50) + 25; | |
}) | |
.attr("cy", h/2) | |
.attr("r", function(d) { | |
return d/2; | |
}); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment