This post describes how to build a donut chart with group labels in d3.js. You can see many other examples in the donut chart section of the gallery. Watch out: pie and donut chart are most of the time a very bad way to convey information as explained in this post.
posA
: line insertion in the sliceposB
: line break positionposC
: label positionposA
is straightforward thanks to the centroid
function of d3. It is used to label pie chart as well.posB,
another arc generator called outerArc
is created. It is not used to draw arcs, but only to compute centroid.posC
has the same Y coordinates than posB
. However its x coordinate is at the extreme part of the svg area.