Skip to content

overpas/compose-treemap-chart

Repository files navigation

Compose Treemap Chart

Maven Central Build Badge-Android Badge-JVM Badge-iOS Badge-JS Badge-Wasm

Jetpack compose treemap chart implementation

Usage

Adding to the project

Add this to your dependencies gradle block:

implementation "io.github.overpas:treemap-chart:0.1.3"
implementation "io.github.overpas:treemap-chart-compose:0.1.3"

Sample code

private val simpleTreeData = tree(10) {
    node(6) {
        node(4)
        node(2) {
            node(1)
            node(1)
        }
    }
    node(3) {
        node(2)
        node(1)
    }
    node(1)
}

@Composable
fun MyChart() {
    TreemapChart(
        data = simpleTreeData,
        evaluateItem = Int::toDouble,
        modifier = Modifier.fillMaxSize(),
    ) { item ->
        SimpleTreemapItem(item = item.toString())
    }
}

The code above produces something like this:

For more advanced Kotlin Multiplatform samples check out the sample directory