donutChart

fun ContainerScope.donutChart(slices: List<ChartSeries>, diameter: Dp, holeRatio: Float = 0.55f, showLegend: Boolean = true)

Appends a donut chart — a pie with a circular hole punched in the centre.

Each entry in slices becomes an annular segment: the outer arc is swept forward, a line drops to the inner radius, the inner arc is swept backward, and the path is closed. Arc approximation matches pieChart (cubic Béziers, k = 4/3·tan(θ/4), ≤90° per cubic). The hole's size is holeRatio of the outer radius.

When showLegend is true (default), the same swatch + label + percentage legend as pieChart is appended.

An empty slices list, or one whose values sum to <= 0, draws nothing.

Parameters

slices

the segments, in draw order from the top, clockwise.

diameter

outer diameter of the donut.

holeRatio

inner-hole radius as a fraction of the outer radius, clamped to 0f..0.95f so the ring never vanishes or inverts.

showLegend

when true, appends a swatch + label + percentage legend.