Charts
Chartsanimated
Area gradient
A single-series area chart with a soft gradient fill under a draw-on line.
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 AreaGradient(
values: List<Float> = listOf(0.7f, 0.55f, 0.6f, 0.38f, 0.46f, 0.28f, 0.34f),
accent: Color = Color(0xFF8B5CF6),
modifier: Modifier = Modifier,
) {
val reveal = remember { Animatable(0f) }
LaunchedEffect(Unit) {
reveal.animateTo(1f, tween(1000, easing = EaseOutCubic))
}
Canvas(modifier.fillMaxWidth().height(120.dp)) {
val step = size.width / (values.size - 1)
val line = Path().apply {
values.forEachIndexed { i, v ->
val x = i * step
val y = size.height * v
if (i == 0) moveTo(x, y) else lineTo(x, y)
}
}
val area = Path().apply {
addPath(line)
lineTo(size.width, size.height)
lineTo(0f, size.height)
close()
}
clipRect(right = size.width * reveal.value) {
drawPath(
area,
brush = Brush.verticalGradient(
listOf(accent.copy(alpha = 0.35f), Color.Transparent),
),
)
drawPath(line, accent, style = Stroke(3.dp.toPx(), cap = StrokeCap.Round))
}
}
}