All examples By author By category About

ialarmedalien

Custom d3 path generation

Demonstration of some odd behaviour of d3-shape's linkTo and arc.

The diagrams are generated from the same set of coordinates run through a function that generates variations on paths; for any line from (x0,y0) to (x1,y1), the options are:

The diagrams demonstrate the odd behaviour of the linkTo and arc commands when used in sequence. The uncorrected radial charts demonstrate the default behaviour, and the corrected charts have -0.5 Pi radians applied to the angles, i.e. for a line from a to b:

Uncorrected

context.arc(0, 0, b.y, a.x, b.x);

Corrected

context.arc(0, 0, b.y, a.x - Math.PI*0.5, b.x - Math.PI*0.5);