Skip to content

Instantly share code, notes, and snippets.

@roippi
Created July 20, 2013 06:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save roippi/6044065 to your computer and use it in GitHub Desktop.
Save roippi/6044065 to your computer and use it in GitHub Desktop.
embedded circles...
<!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