I'm in the process of building a donut chart that is rendered on the server. I got some help in the math around positioning the labels to the center of donut slice here. That solution works well but I'm having another problem with my chart. I don't know how to rotate each svg circle using my current math formula. I can rotate each slice using stroke-dashoffset
but then the text isn't following the slice around the chart.
How can I rotate each slice of the donut chart so that they don't overlap while still keeping the label in the center of the slice?
I think I need to adjust the angle, I'm just unsure how.
Here's what It currently looks like
Here's what I'd like it to look like
Here's the code sandbox I'm working out of https://codesandbox.io/s/goofy-feather-5yyr3.