JetBrains / lets-plot-kotlin

Grammar of Graphics for Kotlin
https://lets-plot.org/kotlin/
MIT License
444 stars 38 forks source link

Discrete scale doesn't work for datetime data. #231

Closed AndreiKingsley closed 7 months ago

AndreiKingsley commented 10 months ago

With default (continuous) scale it works well:

import java.time.Instant.parse

val instants = listOf(
    "2021-01-01T00:00:00Z",
    "2021-02-23T00:00:00Z",
    "2021-04-03T00:00:00Z",
    "2021-05-04T00:00:00Z",
    "2021-10-05T00:00:00Z"
).map(::parse)

val daysData = mapOf<String, Any>(
    "days" to instants,
    "val" to (1..instants.size)
)

letsPlot(daysData) + geomBar() { x = "days"; fill = "days" }
image

But with discrete (via asDiscrete() or scaleFillDiscrete()) formatting is missing (in legend and tooltips)

letsPlot(daysData) + geomBar() { x = "days"; fill = asDiscrete("days") }
image
letsPlot(daysData) + geomBar() { x = "days"; fill = "days" } + scaleFillDiscrete()
image
OLarionova-HORIS commented 7 months ago

Fixed via commit: https://github.com/JetBrains/lets-plot/commit/afefca4f0bf3b3f9f8a1cd6d09af804ea76493ea

alshan commented 7 months ago

Fixed in v4.7.1