Package-level declarations

Types

Link copied to clipboard
class CircularLabelPositionProvider(labelSpacing: Float, labelPlacement: PieLabelPlacement = PieLabelPlacement.External) : LabelPositionProvider

Places labels circularly around the outer perimeter of the pie, adjusting them vertically to not overlap with adjacent labels.

Link copied to clipboard
data class ExternalLabelPosition(val position: Offset, val anchorPoint: Offset, val anchorAngle: AngularValue) : LabelPosition

Specifies positioning values for a Pie Chart slice's external label (the label that is outside the perimeter of the pie).

Link copied to clipboard
data class InternalLabelPosition(val position: Offset) : LabelPosition

Specifies positioning for a Pie Chart slice's internal label (the label is placed within the pie slice).

Link copied to clipboard

The LabelConnectorScope provides geometry information to LabelConnector implementations so they can draw the connector from the graph element to the label.

Link copied to clipboard
sealed interface LabelPosition

Specifies positioning values for a Pie Chart slice label.

Link copied to clipboard

This interface is implemented to provide specific layout algorithms for positioning of Pie Slice labels around the outside of the Pie.

Link copied to clipboard
data object None : LabelPosition

Specifies a label that is not positioned, and should not be displayed. This is used, for example, when only internal slice labels should be used and a label does not fit within its slice.

Link copied to clipboard
sealed interface PieLabelPlacement

Specifies the strategy for placing Pie chart labels.

Link copied to clipboard
data class PieSliceData(val startAngle: AngularValue, val angle: AngularValue)

Defines the angular position of a single Pie Slice in terms of the starting angle for the slice, startAngle, and the angular size of the slice, angle. 0-degrees is to the right and angles increase in the clockwise direction.

Link copied to clipboard

Scope for Pie slices.

Functions

Link copied to clipboard
fun LabelConnectorScope.BezierLabelConnector(modifier: Modifier = Modifier, connectorColor: Color = MaterialTheme.colorScheme.onBackground, connectorStroke: Stroke = Stroke(width = 1f))

A label connector that uses a Bezier curve.

Link copied to clipboard
fun PieSliceScope.DefaultSlice(color: Color, modifier: Modifier = Modifier, border: BorderStroke? = null, hoverExpandFactor: Float = 1.0f, hoverElement: @Composable () -> Unit = {}, clickable: Boolean = false, antiAlias: Boolean = false, gap: Float = 0.0f, onClick: () -> Unit = {})

A default pie chart slice implementation that can form full slices as well as slices with a "hole" for donut charts.

Link copied to clipboard
fun PieChart(values: List<Float>, modifier: Modifier = Modifier, slice: @Composable PieSliceScope.(Int) -> Unit = { val colors = remember(values.size) { generateHueColorPalette(values.size) } DefaultSlice(colors[it]) }, label: @Composable (Int) -> Unit = {}, labelConnector: @Composable LabelConnectorScope.(Int) -> Unit = { StraightLineConnector() }, labelSpacing: Float = DefaultLabelDiameterScale, holeSize: Float = 0.0f, holeContent: @Composable () -> Unit = {}, minPieDiameter: Dp = 100.dp, maxPieDiameter: Dp = 300.dp, forceCenteredPie: Boolean = false, animationSpec: AnimationSpec<Float> = KoalaPlotTheme.animationSpec)

Creates a Pie Chart or, optionally, a Donut Chart if holeSize is nonZero, with optional hole content to place at the center of the donut hole. Pie slices are drawn starting at -90 degrees (top center), progressing clockwise around the pie. Each slice occupies a fraction of the overall pie according to its data value relative to the sum of all values. Places labels around the pie at a minimum distance set by labelSpacing.

fun PieChart(values: List<Float>, labelPositionProvider: LabelPositionProvider, modifier: Modifier = Modifier, slice: @Composable PieSliceScope.(Int) -> Unit = { val colors = remember(values.size) { generateHueColorPalette(values.size) } DefaultSlice(colors[it]) }, label: @Composable (Int) -> Unit = {}, labelConnector: @Composable LabelConnectorScope.(Int) -> Unit = { StraightLineConnector() }, holeSize: Float = 0.0f, holeContent: @Composable () -> Unit = {}, minPieDiameter: Dp = 100.dp, maxPieDiameter: Dp = 300.dp, forceCenteredPie: Boolean = false, animationSpec: AnimationSpec<Float> = KoalaPlotTheme.animationSpec)

Creates a Pie Chart or, optionally, a Donut Chart if holeSize is nonZero, with optional hole content to place at the center of the donut hole. Pie slices are drawn starting at -90 degrees (top center), progressing clockwise around the pie. Each slice occupies a fraction of the overall pie according to its data value relative to the sum of all values.

Link copied to clipboard
fun LabelConnectorScope.StraightLineConnector(modifier: Modifier = Modifier, connectorColor: Color = MaterialTheme.colorScheme.onBackground, connectorStroke: Stroke = Stroke(width = 1f))

A label connector that uses a straight line.