Charts
Chartsanimated

Bubble scatter

A scatter plot of variable-radius bubbles that twinkle in over faint axes.

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 BubbleScatter(
    points: List<Triple<Float, Float, Float>> = listOf(
        Triple(0.15f, 0.7f, 7f), Triple(0.35f, 0.4f, 12f),
        Triple(0.55f, 0.62f, 9f), Triple(0.7f, 0.28f, 15f),
        Triple(0.85f, 0.5f, 8f),
    ),
    accent: Color = Color(0xFF6366F1),
    modifier: Modifier = Modifier,
) {
    val grow by animateFloatAsState(1f, spring(stiffness = 120f), label = "grow")
    val axis = MaterialTheme.colorScheme.outlineVariant
    Canvas(modifier.size(180.dp, 120.dp)) {
        drawLine(axis, Offset(0f, size.height), Offset(size.width, size.height))
        drawLine(axis, Offset(0f, 0f), Offset(0f, size.height))
        points.forEach { (x, y, r) ->
            drawCircle(
                accent.copy(alpha = 0.65f),
                radius = r * grow,
                center = Offset(x * size.width, y * size.height),
            )
        }
    }
}