kotlinhistogram

Kandy - Histograms don't work - Unresolved reference: histogram


I tried to reproduce the simple Kotlin Kandy histogram example at https://kotlin.github.io/kandy/histogram-simple.html.

val random = java.util.Random(42)

val dataframe = dataFrameOf(
    "sample" to List(1000) { random.nextGaussian() }
)

dataframe.plot {
    histogram("sample")
}

However, I get the error:

Unresolved reference: histogram

It seems like the unit tests depend on import org.jetbrains.kotlinx.statistics.kandy.layers.histogram, but I can't find that class anywhere and IntelliJ won't resolve the import.

I'm using these dependencies in a desktop Kotlin project:

dependencies {
  implementation("org.jetbrains.kotlinx:kandy-lets-plot:0.7.1")
  implementation("org.jetbrains.kotlinx:kandy-echarts:0.7.1")
  implementation("org.jetbrains.kotlinx:kandy-util:0.7.1")
  implementation("org.jetbrains.kotlinx:kandy-api:0.7.1")
}

To Reproduce

Steps to reproduce the behavior:

  1. Try demo simple histogram in Kotlin desktop project with main function

Expected behavior

Histogram should be generated:

image

Actual Behavior

Application doesn't build - it can't find histogram

**Related

I opened a bug for this on the Kandy GitHub repo at https://github.com/Kotlin/kandy/issues/443


Solution

  • According to this page, you need an extra dependency for the things in the org.jetbrains.kotlinx.statistics package.

    repositories {
        mavenCentral()
        maven("https://packages.jetbrains.team/maven/p/kds/kotlin-ds-maven")
    }
    
    dependencies {
        implementation("org.jetbrains.kotlinx:kandy-lets-plot:0.7.0")
    
        // this below!
        implementation("org.jetbrains.kotlinx:kotlin-statistics-jvm:0.3.1")
    }