forked from mbostock's block: Arc Corners IV
Created
August 18, 2017 09:01
-
-
Save lx7575000/1b8270e83cd4be665a90bdea85c149f6 to your computer and use it in GitHub Desktop.
Arc Corners IV
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 data = [1, 1, 2, 3, 5, 8, 13, 21]; | |
var width = 960, | |
height = 500, | |
radius = height / 2 - 10; | |
var arc = d3.svg.arc() | |
.innerRadius(radius - 40) | |
.outerRadius(radius) | |
.cornerRadius(20); | |
var pie = d3.layout.pie() | |
.padAngle(.02); | |
var color = d3.scale.category10(); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.append("g") | |
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); | |
svg.selectAll("path") | |
.data(pie(data)) | |
.enter().append("path") | |
.style("fill", function(d, i) { return color(i); }) | |
.attr("d", arc); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment