Skip to content

Instantly share code, notes, and snippets.

@gregorw
Last active June 10, 2016 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gregorw/0de93baf5cbaeefff1fcd550fed3fdc1 to your computer and use it in GitHub Desktop.
Save gregorw/0de93baf5cbaeefff1fcd550fed3fdc1 to your computer and use it in GitHub Desktop.
Arcs
license: gpl-3.0
<!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