kandy icon indicating copy to clipboard operation
kandy copied to clipboard

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

Open Jolanrensen opened this issue 1 year ago • 5 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

Jolanrensen avatar May 06 '24 20:05 Jolanrensen

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.

Jolanrensen avatar May 06 '24 20:05 Jolanrensen

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

AndreiKingsley avatar May 12 '24 20:05 AndreiKingsley

Yes and no:

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

Jolanrensen avatar May 13 '24 10:05 Jolanrensen

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

AndreiKingsley avatar May 13 '24 11:05 AndreiKingsley