A method for automatically finding the best eligible label position and font size for a label that's going to go along a path inside of an area, similar to this example but with two embellishments:
- Using d3plus.polygonRayCast() to more accurately measure the vertical clearance available at a given x position with any rotation.
- Avoiding label positions that would cause the text to be overlapped by another shape for a case like this bump chart.
The measurement gets thrown off a little bit by the curve function and the fact that text is rotated letter by letter instead of continuously, but the results seem good enough.
See also: Automatic label placement along a path Streamgraph label positions #2