I'm using D3.js. I created a text element in svg. I have a element.
<text id="text16" class="text" x="xx" y="yy"
transform="translate(tx,ty)" height="hh"
text-anchor="left"">DC_AAA_BBB_CCC_XXXX</text>
I want to reduce set the width. And when the text element width is smaller that the raw text's length(calculated from .getComputedTextLength), I want it to show up to the text element width. Such that only up to "DC_AAA_BBB_" is shown when raw text length is longer.
I've tried adding css -> width: 100px; Also tried adding width attribute in DOM -> width="100px"
Both did not work. How can I achieve this? Thanks!