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 StackedBars(
cols: List<List<Float>> = listOf(
listOf(0.3f, 0.25f, 0.2f), listOf(0.4f, 0.2f, 0.15f),
listOf(0.25f, 0.35f, 0.18f), listOf(0.45f, 0.22f, 0.2f),
listOf(0.3f, 0.3f, 0.25f),
),
palette: List<Color> = listOf(Color(0xFF6366F1), Color(0xFF22D3EE), Color(0xFFA78BFA)),
modifier: Modifier = Modifier,
) {
val grow by animateFloatAsState(1f, tween(1000, easing = EaseOutCubic), label = "g")
Canvas(modifier.fillMaxWidth().height(130.dp)) {
val gap = 12.dp.toPx()
val bw = (size.width - gap * (cols.size - 1)) / cols.size
cols.forEachIndexed { i, segs ->
val x = i * (bw + gap)
var yBottom = size.height
segs.forEachIndexed { s, frac ->
val h = size.height * frac * grow
drawRect(palette[s], Offset(x, yBottom - h), Size(bw, h))
yBottom -= h
}
}
}
}