テキストの幅と高さ、および四角形の幅と高さに基づいて、テキストを四角形の中央に配置したいと考えています。以下の SVG コードを参照してください。
<g transform="translate(73,535)" id="container_svg_ToolTip">
<rect id="container_svg_SvgRect" x="314.58333333333337" y="-85.60000000000001" width="16" height="16" fill="white" stroke-width="1" stroke="Black"/>
<text id="container_svg_ToolTipText_4" x="314.58333333333337" y="-85.60000000000001" fill="black" font-size="12px" font-family="Times New Roman" font-style="Normal " text-anchor="start" clip-path="url(#container_svg_ChartAreaClip)" dominant-baseline="middle">40
</text></g>
最大テキスト サイズ (幅と高さ) に基づいて四角形の幅と高さを設定し、テキストを四角形の中央に配置したいと考えています。これを行うには計算が必要です。下のリンクのようなrectX+10、rectY+10のようなパディング値を追加する必要はありません。
以下のスクリーンショットを参照してください。
ありがとう、
シヴァ