Open DylanBrass opened 9 months ago
Confirmed. I took a look, and I'm not entirely sure what's wrong here. It almost seems like the transform origin is set incorrectly for <Text>
elements inside react-pdf
. You can see the labels rotate, but not relative to their element.
Thank you, I thought I was going crazy haha, I wish I could help but I have near 0 experience with SVG's.
looks like you are adding an angle to a group of text items (as you said the axis) rather to each text item (ie the label)...
btw this helped me find my issue which I can fix. (not sure I can fix yours but will revert if I do)
This is going to sound really dumb, but I fixed my radar chart issue with a small pnpm patch that resets the text transform rotate to 0 for elements with a specific class.
You can see the <PolarRadiusAxis>
ticks being completely off here:
When I set the angle to 90, it's fixed, but I don't want the angle to be in the center:
https://github.com/EvHaus/react-pdf-charts/blob/dev/src/index.tsx#L305
case "text":
if (baseProps.transform && attribs.class ===
"recharts-text recharts-polar-radius-axis-tick-value") {
baseProps.transform = baseProps.transform.replace(/rotate\(60(?=,)/g, 'rotate(0')
}
return renderTextElement({
baseProps,
chartStyle,
children: children2,
node
});
This is by no means perfect, but it's close enough for me. Not sure if this helps in diagnosing the root issue.
Describe the bug
Whenever you put an angle like so :
It will either disapear (when -90 or 90 +) or got to the middle.
I am using React and Typescript, plus Rechart, all newest versions.
Reproduction
Validations