Question:
I am working with a SVG element as following. In this I am using<textPath></textPath>
to place a text on a path.The svg is following
My end goal is to place each text just above the path so that the text is clearly visible. To achieve that, I tried the following which did not work. the label for
24.7%
is pushed far down.Is there a way to programatically achieve this?
Answer:
You could achieve a baseline offset by adjustingdominant-baseline
and dy
values like so:dominant-baseline="hanging"
will position your text under your
<textPath>
dy="10"
allows you to finetune the vertical alignment further:
Quite often capital letters ascenders will collide with your
<textPath>
.If you have better answer, please add a comment about this, thank you!