Charts
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 SlopeChart(
pairs: List<Triple<String, Float, Float>> = listOf(
Triple("A", 0.3f, 0.7f), Triple("B", 0.6f, 0.5f),
Triple("C", 0.8f, 0.9f), Triple("D", 0.45f, 0.2f),
),
modifier: Modifier = Modifier,
) {
val draw = remember { Animatable(0f) }
LaunchedEffect(Unit) { draw.animateTo(1f, tween(900, easing = EaseOutCubic)) }
val axis = MaterialTheme.colorScheme.outlineVariant
val palette = listOf(Color(0xFF6366F1), Color(0xFF10B981), Color(0xFFF59E0B), Color(0xFFF43F5E))
Canvas(modifier.size(180.dp, 120.dp)) {
val pad = 8.dp.toPx()
val lx = pad
val rx = size.width - pad
drawLine(axis, Offset(lx, 0f), Offset(lx, size.height))
drawLine(axis, Offset(rx, 0f), Offset(rx, size.height))
pairs.forEachIndexed { i, (_, l, r) ->
val ly = size.height * (1f - l)
val ry = size.height * (1f - r)
val c = palette[i % palette.size]
drawLine(c, Offset(lx, ly), Offset(lx + (rx - lx) * draw.value, ly + (ry - ly) * draw.value), 2.5.dp.toPx())
drawCircle(c, 4.dp.toPx(), Offset(lx, ly))
if (draw.value > 0.98f) drawCircle(c, 4.dp.toPx(), Offset(rx, ry))
}
}
}