How do I get the width of the "g" and the width of the "text" and use it for subsequent calculations
const CustomizedAxisTick: React.FunctionComponent<ICustomTickProps> = ({x,y,payload,width,fill}) => {
const firstLine = 12
const secondLine = 24
const dateTime = payload.value
return (
<g transform={`translate(${x},${y})`}>
<text fontFamily="Roboto, sans-serif" transform={"rotate(-45)"} width={width} height="auto" textAnchor="middle" fontSize={12} fill={fill}>
</text>
</g>
);
}
Try using "ref" for the elements: https://reactjs.org/docs/refs-and-the-dom.html
from the ref you can get the clientHeight / offsetHeight and clientWidth / offsetWidth.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.