Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 8, 2016 23:35
Show Gist options
  • Save mbostock/846688 to your computer and use it in GitHub Desktop.
Save mbostock/846688 to your computer and use it in GitHub Desktop.
Circular Layout
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var svg = d3.select("body").append("svg")
.attr("width", 960)
.attr("height", 500)
.append("g")
.attr("transform", "translate(480,250)");
var g = svg.selectAll("g")
.data(d3.range(0, 360, 2))
.enter().append("g")
.attr("transform", function(d) { return "rotate(" + d + ")"; });
var circle = g.selectAll("circle")
.data(d3.range(10))
.enter().append("circle")
.attr("cx", d3.scale.linear().domain([0, 9]).range([180, 240]))
.attr("r", 4.5)
.attr("fill", d3.scale.linear().domain([0, 9]).range(["brown", "steelblue"]))
.attr("stroke", "black");
</script>
@Kreozot
Copy link

Kreozot commented Aug 18, 2015

Please replace the d3 reference to this: https://cdnjs.cloudflare.com/ajax/libs/d3/1.29.5/d3.min.js
Because now the example is not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment