Instantly share code, notes, and snippets.

@d3indepth /.block
Last active Aug 2, 2017

Embed
What would you like to do?
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