PieChart

fun PieChart(data: ChartData, modifier: Modifier = Modifier, style: PieChartStyle = PieChartDefaults.style(), title: String? = null, selectedValueFormatter: ChartValueFormatter = PieChartDefaults.selectedValueFormatter, selection: ChartSelection = rememberChartSelection(), interactionEnabled: Boolean = true, animateOnStart: Boolean = true, subtitle: String? = null)(source)

A composable function that displays a Pie Chart.

A pie is one series whose values are the slices. Categories are optional and name the slices in the legend and while they are selected; when present, there must be one per value. The slice colors come from the style, either as an explicit palette or as shades generated from its base color.

interactionEnabled disables user controls (tap-to-select and the auto-deselect timeout), but programmatic selection still renders. animateOnStart controls the initial reveal, not subsequent update animations.

Parameters

data

The chart data to display. One series of at least two nonnegative finite values. Categories are optional; when supplied they must match the value count. Invalid data renders the documented errors instead of a chart.

modifier

The modifier to be applied to the chart. Also forwarded to the error branch when the data fails validation.

style

The style to be applied to the chart. If not provided, the default style will be used.

title

Optional chart title displayed when no slice is selected.

selectedValueFormatter

Formats the selected slice's share, in percent from 0 to 100.

selection

The hoisted selection state. Use rememberChartSelection for interactive charts or io.github.hdcharts.core.model.staticChartSelection for deterministic preset selections.

interactionEnabled

When false, disables tap-to-select and the auto-deselect timeout.

animateOnStart

When false, renders the chart in its final state without the initial reveal animation.

subtitle

Text below the title that stays visible while a value is selected.