Skip to content

Instantly share code, notes, and snippets.

@d3indepth
Last active September 29, 2019 09:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save d3indepth/ef3c33c21668db4217bf538cff522d5b to your computer and use it in GitHub Desktop.
Save d3indepth/ef3c33c21668db4217bf538cff522d5b to your computer and use it in GitHub Desktop.
Arc generator (padding and radius)
license: gpl-3.0
height: 230
border: no
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>Arc generator (padding and radius)</title>
</head>
<style>
path {
fill: orange;
}
</style>
<body>
<svg width="700" height="220">
<g transform="translate(300, 110)"></g>
</svg>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script>
<script>
var arcGenerator = d3.arc()
.innerRadius(20)
.outerRadius(100)
.padAngle(.02)
.padRadius(100)
.cornerRadius(4);
var arcData = [
{startAngle: 0, endAngle: 0.2},
{startAngle: 0.2, endAngle: 0.6},
{startAngle: 0.6, endAngle: 1.4},
{startAngle: 1.4, endAngle: 3},
{startAngle: 3, endAngle: 2* Math.PI}
];
d3.select('g')
.selectAll('path')
.data(arcData)
.enter()
.append('path')
.attr('d', arcGenerator);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment