Radial line generator.
From D3 in Depth book by Peter Cook.
license: gpl-3.0 | |
height: 210 | |
border: no |
Radial line generator.
From D3 in Depth book by Peter Cook.
<!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> |