Skip to main content
100%

Donut Centroid

✓ Published0🌍 Public
Mmbostock
Last edited Jul 21, 2019
Created on Dec 29, 2015

A donut chart uses the golden ratio as its data values. The chart renders a ring of colored arcs on Canvas, with a black dot at the midpoint of each arc. That midpoint comes from `d3.arc`’s `centroid` method, which is positioned for label placement rather than as a geometric center. The example calls `d3.pie` to compute the arc angles, `d3.arc` to draw the shapes, and `d3.symbol` to draw the dot markers.

AI-generated description

The black dots show the midpoint computed by d3-shape’s arc.centroid. Note that this is not the geometric center of the arc, which may be outside the arc; this method is merely a convenience for positioning labels.

gpl-3.0 Licensed

Similar vizzes