Last active
February 8, 2016 23:37
-
-
Save mbostock/846710 to your computer and use it in GitHub Desktop.
Circular Layout (Recursive)
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
license: gpl-3.0 |
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> | |
<meta charset="utf-8"> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script> | |
var radius = d3.scale.linear() | |
.domain([0, 9]) | |
.range([180, 240]); | |
var fill = d3.scale.linear() | |
.domain([0, 9]) | |
.range(["brown", "steelblue"]); | |
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(10)) | |
.enter().append("g") | |
.attr("fill", fill) | |
.attr("stroke", "black") | |
.each(path); | |
function path(p, j) { | |
d3.select(this) | |
.selectAll("path") | |
.data(d3.range(0, 2 * Math.PI, Math.PI / 90)) | |
.enter().append("path") | |
.attr("d", d3.svg.arc() | |
.innerRadius(radius(p)) | |
.outerRadius(radius(p + 1)) | |
.startAngle(function(d) { return d; }) | |
.endAngle(function(d) { return d + Math.PI / 90; })) | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.