Charts
Chartsanimated

Lollipop

A lollipop chart with thin stems and dots that pop in along the baseline.

Installation

caveui components are copy-paste Jetpack Compose built entirely on Material 3 — there's no caveui dependency to add. Make sure Material 3 is on your classpath (it ships with the Compose BOM), then copy the Usage snippet below into your project.

kotlin
// build.gradle.kts (module)
dependencies {
    implementation(platform("androidx.compose:compose-bom:2025.06.00"))
    implementation("androidx.compose.material3:material3")
}

Usage

kotlin
@Composable
fun Lollipop(
    values: List<Float> = listOf(0.5f, 0.78f, 0.62f, 0.9f, 0.46f, 0.7f),
    accent: Color = Color(0xFFEC4899),
    modifier: Modifier = Modifier,
) {
    val pop by animateFloatAsState(1f, spring(0.55f, 320f), label = "pop")
    val stem = MaterialTheme.colorScheme.outlineVariant
    Canvas(modifier.fillMaxWidth().height(124.dp)) {
        val step = size.width / values.size
        values.forEachIndexed { i, v ->
            val x = step * i + step / 2
            val y = size.height * (1f - v)
            drawLine(stem, Offset(x, size.height), Offset(x, y), 2.dp.toPx())
            drawCircle(accent, 6.dp.toPx() * pop, Offset(x, y))
        }
    }
}