Awesome job!
Yeah, calculating trigonometry through a pack isn’t the most performant thing. I’d rather not calculate the sines and cosines in Coda if I didn’t have to, but rather set transformations in SVG itself (you can make straight lines, wrap them in <g>
groups and set rotation on the latter, specifying the angle and the pivot point IIRC) Then the browser would apply rotation natively and very fast.
You could actually put both the line, the dot, and the text label in such group (assume it’s not rotated) and then apply the rotation onto the whole group at once.
P.S. Actually I see you’re already doing that with text — but apparently still use the trig pack to calculate x/y to draw the lines? You could just do the same with lines as you do with text.
P.P.S. Minor perfectionist’s peeve: for labels you’re using the baseline as the pivot coordinate, hence they look a bit off. So you may want to pre-translate them a bit so that the “line” goes through the optical middle of the text:
In my case, the radar chart, I couldn’t avoid calculating the sines/cosines myself because I had to draw polygons. If I had to do this for a large number of data points, I’d probably pre-load my Coda doc with a sine lookup table, e.g. pre-calculate all angles between 0 and 90 with a step of 0.5 degrees, and then simply linearly interpolate. It wouldn’t be extra accurate but it would be good enough for visualization.