Kotlin/kandy

Incorrect implementation of `scaleXTime()`/`scaleYTime()` "time delta" scales

Jolanrensen opened this issue · 4 comments

Let's plot allows an axis to be scaled as a continuous time delta or "duration".
I currently cannot find a way to easily plot a Duration like a number of hours/days/minutes etc.

For example:
https://nbviewer.org/github/JetBrains/lets-plot-kotlin/blob/master/docs/examples/jupyter-notebooks/scale_time.ipynb

from: https://github.com/JetBrains/lets-plot-kotlin/blob/master/plot-api/src/commonMain/kotlin/org/jetbrains/letsPlot/scale/DateTime.kt

Oh actually, I see scaleXTime() is used in Kandy, but only for timeTypes (LocalTime and LocalTime?).

That may be incorrect usage, actually. I think scaleXDateTime is used for points in time, so Instant, LocalDateTime, but also LocalTime, and then scaleXTime is used for time deltas, so Duration or number of milliseconds.

So basically you want kandy to handle Duration in the same way as LocalTime/LocalDateTime?

Yes and no:

  • Instant, LocalDateTime, and LocalTime should use scaleXDateTime.
  • Duration, and Period should use scaleXTime

Hmm, I guess you're right. I need to do a little research and see if it works correctly, but in terms of implementation it won't be resource intensive at all - just need to take milliseconds value of your duration/period and apply scaleTime().