Kotlin / kandy

Kotlin plotting library.
https://kotlin.github.io/kandy/
Apache License 2.0
581 stars 12 forks source link

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

Open Jolanrensen opened 4 months ago

Jolanrensen commented 4 months ago

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

Jolanrensen commented 4 months ago

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.

AndreiKingsley commented 4 months ago

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

Jolanrensen commented 4 months ago

Yes and no:

AndreiKingsley commented 4 months ago

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().