I've drawn an arc using D3.js which by default has square shaped ends.
var arc = d3.arc()
.innerRadius(0)
.outerRadius(100)
.startAngle(0)
.endAngle(Math.PI);
d3.selectAll('svg')
.append('path')
.attr('d', function() {
return arc();
});
How can I draw an arc with a chevron shape on one end of it.
I would just use d3's path generator with an SVG marker. Add any shape to any path. Edit the "ends" by editing the marker definition. Use D3 path generator to define your arc (or any path).
It's worth noting that if you take this approach you have to use the d3 path generator rather than the d3 arc generator because the arc generator implicitly closes the path (putting your "end" marker back at the beginning of the path).
In my example, I added the chevron to the start as well just to show that it's as trivial as adding .attr("marker-start","url(#chevron)")
and .attr("marker-end","url(#chevron)")
D3 Path Generator | https://github.com/d3/d3-path/blob/master/README.md#path
SVG Markers | https://developer.mozilla.org/en-US/docs/Web/SVG/Element/marker
edit: and now that I think of it, you can probably use d3.symbols to generate your markers/ends for you instead of manually defining the shape path. The chevron would have to be custom, but you could probably use the triangle symbol.
D3 Symbols | https://github.com/d3/d3-shape#symbols
console.clear()
var path = d3.path()
path.arc(225,80,70,1,-.5)
var path2 = d3.path()
path2.moveTo(20,20)
path2.bezierCurveTo(150,300,200,0,450,100)
d3.select("svg").append("path")
.attr("d", path2.toString())
.attr("stroke","steelblue")
.attr("fill","none")
.attr("stroke-width","20")
.attr("marker-start","url(#chevron)")
.attr("marker-end","url(#chevron)")
d3.select("svg").append("path")
.attr("d", path.toString())
.attr("stroke","#43A2CA")
.attr("fill","none")
.attr("stroke-width","20")
.attr("marker-start","url(#chevron)")
.attr("marker-end","url(#chevron)")
<script src="https://unpkg.com/d3@4.4.0"></script>
<?xml version="1.0"?>
<svg width="500" height="200" viewBox="0 0 500 200">
<defs>
<marker id="chevron"
viewBox="0 0 20 20" refX="10" refY="10"
markerUnits="userSpaceOnUse"
markerWidth="20" markerHeight="20"
orient="auto" fill="black">
<path d="M0 0 10 0 20 10 10 20 0 20 10 10Z" />
</marker>
</defs>
</svg>