Skip to content

Instantly share code, notes, and snippets.

@d3indepth
Last active May 31, 2017 11:11
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 d3indepth/3bb2dc908c090e8d2405257caadb20fa to your computer and use it in GitHub Desktop.
Save d3indepth/3bb2dc908c090e8d2405257caadb20fa to your computer and use it in GitHub Desktop.
Arc generator
license: gpl-3.0
height: 120
border: no
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>Arc generator</title>
</head>
<style>
path {
fill: orange;
}
</style>
<body>
<svg width="700" height="110">
<g transform="translate(300, 110)"></g>
</svg>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script>
<script>
// Create an arc generator with configuration
var arcGenerator = d3.arc();
// Generate the path string
var pathData = arcGenerator({
startAngle: 0,
endAngle: 0.25 * Math.PI,
innerRadius: 50,
outerRadius: 100
});
// Create a path element and set its d attribute
d3.select('g')
.append('path')
.attr('d', pathData);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment