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 Waterfall(
deltas: List<Float> = listOf(0.5f, 0.2f, -0.15f, 0.25f, -0.1f),
up: Color = Color(0xFF22C55E),
down: Color = Color(0xFFF43F5E),
modifier: Modifier = Modifier,
) {
val grow by animateFloatAsState(1f, tween(1000, easing = EaseOutCubic), label = "g")
val connector = MaterialTheme.colorScheme.outlineVariant
Canvas(modifier.fillMaxWidth().height(128.dp)) {
val gap = 14.dp.toPx()
val bw = (size.width - gap * (deltas.size - 1)) / deltas.size
var cum = 0f
deltas.forEachIndexed { i, d ->
val x = i * (bw + gap)
val start = size.height * (1f - cum)
val end = size.height * (1f - (cum + d) * grow)
val top = minOf(start, end)
val h = abs(start - end)
drawRoundRect(
if (d >= 0) up else down,
Offset(x, top), Size(bw, h),
CornerRadius(3.dp.toPx()),
)
if (i < deltas.lastIndex) {
drawLine(connector, Offset(x + bw, end), Offset(x + bw + gap, end), 1.5.dp.toPx())
}
cum += d
}
}
}