Jetpack compose treemap chart implementation
Add this to your dependencies
gradle block:
implementation "io.github.overpas:treemap-chart:0.1.0"
implementation "io.github.overpas:treemap-chart-compose:0.1.0"
private val simpleTreeData = tree(10) {
node(6) {
node(4)
node(2) {
node(1)
node(1)
}
}
node(3) {
node(2)
node(1)
}
node(1)
}
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
ComposetreemapchartTheme {
Surface(color = MaterialTheme.colors.background) {
TreemapChart(
data = simpleTreeData,
evaluateItem = { it.toDouble() },
treemapChartMeasurer = remember { SquarifiedMeasurer() },
modifier = Modifier
.fillMaxHeight()
.fillMaxWidth(),
) { item ->
SimpleTreemapItem(item = item.toString())
}
}
}
}
}
}
The code above produces something like this:
For more advanced Kotlin Multiplatform samples check out the /sample directory