Charts
Chartsanimated

Radar stats

A five-axis radar chart with a translucent data polygon and twinkling vertices.

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 RadarStats(
    values: List<Float> = listOf(0.9f, 0.6f, 0.75f, 0.45f, 0.8f),
    accent: Color = Color(0xFF8B5CF6),
    modifier: Modifier = Modifier,
) {
    val grow by animateFloatAsState(1f, tween(900, easing = EaseOutBack), label = "grow")
    val grid = MaterialTheme.colorScheme.outlineVariant
    Canvas(modifier.size(160.dp)) {
        val r = size.minDimension / 2f * 0.82f
        val n = values.size
        fun vertex(i: Int, radius: Float): Offset {
            val a = -PI / 2 + i * 2 * PI / n
            return center + Offset(cos(a).toFloat() * radius, sin(a).toFloat() * radius)
        }
        for (ring in 1..3) {
            val rr = r * ring / 3f
            val grpath = Path().apply {
                repeat(n) { i ->
                    val p = vertex(i, rr)
                    if (i == 0) moveTo(p.x, p.y) else lineTo(p.x, p.y)
                }
                close()
            }
            drawPath(grpath, grid, style = Stroke(1.dp.toPx()))
        }
        val data = Path().apply {
            repeat(n) { i ->
                val p = vertex(i, r * values[i] * grow)
                if (i == 0) moveTo(p.x, p.y) else lineTo(p.x, p.y)
            }
            close()
        }
        drawPath(data, accent.copy(alpha = 0.25f))
        drawPath(data, accent, style = Stroke(2.dp.toPx()))
    }
}