Last active
June 10, 2016 06:45
-
-
Save gregorw/0de93baf5cbaeefff1fcd550fed3fdc1 to your computer and use it in GitHub Desktop.
Arcs
This file contains hidden or 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 hidden or 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> | |
.paths--round { | |
fill: #ccc; | |
} | |
</style> | |
<body> | |
<script src="//d3js.org/d3.v3.min.js"></script> | |
<script> | |
var data = [3, 8, 21]; | |
var width = 960, | |
height = 500, | |
thickness = 20 | |
outerRadius = height / 2 - 30, | |
innerRadius = outerRadius - thickness; | |
var pie = d3.layout.pie() | |
.padAngle(.03); | |
var arc = d3.svg.arc() | |
.innerRadius(innerRadius) | |
.outerRadius(outerRadius); | |
var svg = d3.select("body").append("svg") | |
.attr("width", width) | |
.attr("height", height) | |
.append("g") | |
.attr("transform", "translate(" + width / 2 + "," + height / 2 + ")"); | |
var roundPath = svg.append("g") | |
.attr("class", "paths--round") | |
.selectAll("path") | |
.data(data) | |
.enter().append("path"); | |
roundPath.data(pie(data)).attr("d", arc.cornerRadius((outerRadius - innerRadius) / 2)); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment