Charts
Chartsanimated

Beeswarm

A beeswarm of jittered dots along an axis that twinkle into their positions.

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 Beeswarm(
    points: List<Pair<Float, Float>> = remember { sampleSwarm(40) },
    accent: Color = Color(0xFF0EA5E9),
    modifier: Modifier = Modifier,
) {
    val pop by animateFloatAsState(1f, spring(0.6f, 180f), label = "pop")
    val axis = MaterialTheme.colorScheme.outlineVariant
    Canvas(modifier.fillMaxWidth().height(110.dp)) {
        val mid = size.height / 2
        drawLine(axis, Offset(0f, mid), Offset(size.width, mid), 1.5.dp.toPx())
        points.forEach { (x, jitter) ->
            drawCircle(
                accent.copy(alpha = 0.75f),
                4.dp.toPx() * pop,
                Offset(x * size.width, mid + jitter * mid * 0.8f),
            )
        }
    }
}