Arc generator (configured).
From D3 in Depth book by Peter Cook.
license: gpl-3.0 | |
height: 120 | |
border: no |
Arc generator (configured).
From D3 in Depth book by Peter Cook.
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<head> | |
<title>Arc generator (configured)</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() | |
.innerRadius(20) | |
.outerRadius(100); | |
// Generate the path string | |
var pathData = arcGenerator({ | |
startAngle: 0, | |
endAngle: Math.PI / 4 | |
}); | |
// Create a path element and set its d attribute | |
d3.select('g') | |
.append('path') | |
.attr('d', pathData); | |
</script> | |
</body> | |
</html> |