Skip to content

Instantly share code, notes, and snippets.

@d3indepth
Last active August 2, 2017 11:23
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/39d798286a4bf92cee446add65290d70 to your computer and use it in GitHub Desktop.
Save d3indepth/39d798286a4bf92cee446add65290d70 to your computer and use it in GitHub Desktop.
Radial line generator
license: gpl-3.0
height: 210
border: no
<!DOCTYPE html>
<meta charset="utf-8">
<head>
<title>Radial line generator</title>
</head>
<style>
path {
fill: none;
stroke: #999;
}
</style>
<body>
<svg width="700" height="200">
<g transform="translate(100,100)"></g>
</svg>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.min.js"></script>
<script>
var radialLineGenerator = d3.radialLine();
var points = [
[0, 80],
[Math.PI * 0.25, 80],
[Math.PI * 0.5, 30],
[Math.PI * 0.75, 80],
[Math.PI, 80],
[Math.PI * 1.25, 80],
[Math.PI * 1.5, 80],
[Math.PI * 1.75, 80],
[Math.PI * 2, 80]
];
var radialLine = radialLineGenerator(points);
d3.select('g')
.append('path')
.attr('d', radialLine);
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment