Last active
February 9, 2016 00:01
-
-
Save mbostock/938288 to your computer and use it in GitHub Desktop.
Banded Arcs
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"> | |
<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