Getting Started

Quickly get started with Koala Plot

Repositories

Add the mavenCentral and compose repositories to your project’s build.gradle.kts

1
2
3
4
5
repositories {
    google()
    mavenCentral()
    maven("https://maven.pkg.jetbrains.space/public/p/compose/dev")
    mavenLocal()

Including mavenLocal() is optional, if you want to use pre-release builds you create locally.

Dependencies

Include Koala Plot core as a dependency in your project’s build.gradle.kts

1
                implementation(compose.ui)

You can also see a complete example of a build.gradle.kts in the samples.

First Plot

The below plots the function \( y=x^2 \) with x from 1 to 10:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
    val data = buildList {
        for (i in 1..10) {
            add(DefaultPoint(i.toFloat(), i * i.toFloat()))
        }
    }

    XYGraph(
        rememberFloatLinearAxisModel(data.autoScaleXRange()),
        rememberFloatLinearAxisModel(data.autoScaleYRange())
    ) {
        LinePlot(
            data,
            lineStyle = LineStyle(SolidColor(Color.Blue))
        )
    }
/examples/src/jvmMain/kotlin/io/github/koalaplot/example/Line1.kt

Line1


Last modified November 22, 2023: Add website (6de4820)