https://github.com/korlibs/korge-charts
https://github.com/korlibs/korge-charts
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/korlibs/korge-charts
- Owner: korlibs
- License: mit
- Created: 2023-11-26T12:07:15.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2024-03-26T11:39:05.000Z (about 2 years ago)
- Last Synced: 2025-09-01T20:55:41.659Z (9 months ago)
- Language: Kotlin
- Size: 117 KB
- Stars: 3
- Watchers: 4
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# korge-charts
Charts
This provides support to display basic charts. The goal is to keep the code simple and provide some customization options.
The functions available are:
- lineChart
- barChart
- pieChart
- spiderGraph
---
```kotlin
lineChart(Size(200, 100)) {
position(50, 50)
lineColor = Colors.RED
axlesColor = Colors["#85847f"]
hintsColor = Colors.WHITE
updateData(
listOf(
Point(15, 55),
Point(22, 33),
Point(111, 222),
Point(433, 312),
),
xHints = listOf(100.0, 200.0, 300.0, 400.0),
yHints = listOf(300.0, 600.0, 900.0),
showHintLabels = true,
)
}
```

---
Code examples:
```kotlin
barChart(Size(200, 100)) {
position(50, 50)
updateData(
listOf(
"low" to 1f,
"medium" to 2f,
"high" to 3f,
)
)
}
```

---
```kotlin
pieChart(70f) {
position(50, 50)
setColors(
listOf(
Colors["#73ff5f"],
Colors["#4058ff"],
Colors["#1efff8"],
Colors["#ff0b00"],
)
)
updateData(
listOf(
"example" to 10f,
"another" to 30f,
"very cool" to 5f,
"exampleeee" to 15f,
)
)
}
```

---
```kotlin
spiderGraph(100f, 30f) {
position(50, 50)
updateData(listOf(15f, 16f, 11f, 15f, 16f))
backgroundColor = Colors["#1014c5"]
foregroundColor = Colors["#16c542"].withA(140)
updateData(listOf(10f, 13f, 29f, 25f, 11f, 26f, 23f))
val strings = listOf("Speed", "Agility", "Strength", "Luck", "Intelligence", "Wisdom", "Charm")
getEdgeContainers().forEachIndexed { idx, container ->
container.apply {
text(strings[idx])
}
}
getValueContainers().forEach {
it.apply {
circle(3) {
anchor(.5, .5)
}
}
}
}
```
