Charts
Chartsanimated
Marimekko
A Marimekko chart of variable-width columns, each a 100% stacked segment set.
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 Marimekko(
widths: List<Float> = listOf(0.34f, 0.26f, 0.22f, 0.18f),
stacks: List<List<Float>> = listOf(
listOf(0.5f, 0.3f, 0.2f), listOf(0.35f, 0.4f, 0.25f),
listOf(0.6f, 0.25f, 0.15f), listOf(0.3f, 0.45f, 0.25f),
),
palette: List<Color> = listOf(Color(0xFF6366F1), Color(0xFF22D3EE), Color(0xFFA78BFA)),
modifier: Modifier = Modifier,
) {
val reveal by animateFloatAsState(1f, tween(900, easing = EaseOutCubic), label = "r")
Canvas(modifier.fillMaxWidth().height(130.dp)) {
val gap = 3.dp.toPx()
var x = 0f
widths.forEachIndexed { i, w ->
val colW = (size.width - gap * (widths.size - 1)) * w
var y = size.height
stacks[i].forEachIndexed { s, frac ->
val h = size.height * frac
drawRect(palette[s], Offset(x, (y - h)), Size(colW * reveal, h))
y -= h
}
x += colW + gap
}
}
}