Skip to content

Instantly share code, notes, and snippets.

@mbostock
Last active February 9, 2016 00:01
Show Gist options
  • Save mbostock/938288 to your computer and use it in GitHub Desktop.
Save mbostock/938288 to your computer and use it in GitHub Desktop.
Banded Arcs
license: gpl-3.0
<!DOCTYPE html>
<meta charset="utf-8">
<style>
path {
fill: lightsteelblue;
stroke: steelblue;
}
</style>
<body>
<script src="//d3js.org/d3.v3.min.js"></script>
<script>
var width = 960,
height = 500;
var data = d3.range(20);
var angle = d3.scale.ordinal()
.domain(data)
.rangeBands([0, 2 * Math.PI]);
d3.select("body").append("svg")
.attr("width", width)
.attr("height", height)
.append("g")
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")")
.selectAll("path")
.data(data)
.enter().append("path")
.attr("d", d3.svg.arc()
.innerRadius(height / 2 - 20)
.outerRadius(height / 2 - 10)
.startAngle(function(d) { return angle(d); })
.endAngle(function(d) { return angle(d) + angle.rangeBand() / 2; }));
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment