score:5

Accepted answer

I think you should be using "x" instead of "dx" to place the labels. Figure you want the text at that x position and anchored on the middle. dx is meant to offset from the anchored position I think.

Similarly you probably mean to use "y" instead of "dy". Use dy to adjust the height above or below the baseline (often in "em" units) and y to actually position the text.

Try:

<svg width="650" height="400">
 <g class="groups" transform="translate(25,0)">
  <g class="group" transform="translate(0,0)">
   <g class="bar"><rect class="subBar" x="0" y="60" width="192" height="310"/></g>
   <g class="dataLabel"><text text-anchor="middle" class="subLabel" style="font-size: 14px; opacity: 1;" x="96.25" y="55">83%</text></g>
  </g>
  <g class="group" transform="translate(207.5,0)">
   <g class="bar"><rect class="subBar" x="0" y="97.22891566265059" width="192" height="272.7710843373494"/></g>
   <g class="dataLabel"><text text-anchor="middle" class="subLabel" style="font-size: 14px; opacity: 1;" x="96.25" y="92.22891566265059">73%</text></g>
  </g>
  <g class="group" transform="translate(415,0)">
   <g class="bar"><rect class="subBar" x="0" y="93.50602409638549" width="192" height="276.4939759036145"/></g>
   <g class="dataLabel"><text text-anchor="middle" class="subLabel" style="font-size: 14px; opacity: 1;" x="96px" y="88.50602409638549">74%</text></g>
  </g>
 </g>
</svg>

score:0

You're using dx and dy to position the text when you should be using x and y


Related Query

More Query from same tag