Closed ialarmedalien closed 5 years ago
This is the expected behavior; context.arc defines angles by measuring clockwise from the positive x-axis (3 o’clock), whereas d3-shape measures clockwise from the negative y-axis (12 o’clock). This is documented in the definition of d3.pointRadial. (It’s also more convenient for pie charts and such.)
I've written some code to generate different styles of link in node-link diagrams (dogleg, right angle, direct lines, etc.) and came across an odd bug when using
d3.pointRadial
,context.lineTo
, andcontext.arc
.Given an set of points, x0,y0, x1,y1, x2,y2, etc., representing angle and radius, I assumed I would be able to do something like this:
etc.
However, the
arc
command puts in an extra .5 Pi radians somewhere, so if I want the lines to join nicely, I have to use these arguments:I couldn't see anything in the docs about it. Is this how the
arc
function is supposed to work?I've created an example block to demonstrate the problem.
On a related note, it would be very useful to have a publicly-exported
link
function to allow the easy creation of custom links with the same interface aslinkHorizontal
,linkVertical
, andlinkRadial
. I'm using a slightly edited version ofd3-shape
that exposes thelink
constructor, but it would be great to have something official.