Replies: 11 comments
-
Hello @abderhim, you can use |
Beta Was this translation helpful? Give feedback.
-
then we can't pass Timestamps with ms as X values, because we can't get the exact values when we convert it to Float :( |
Beta Was this translation helpful? Give feedback.
-
A very similar use case is already described in the wiki here. |
Beta Was this translation helpful? Give feedback.
-
that will not cover Timestamps with ms , when converting to Float , data will be lost |
Beta Was this translation helpful? Give feedback.
-
Hello! Millisecond-based timestamps are typically whole numbers, and no rounding errors should occur for such values. The first six decimal digits should be accurate too. Unless you require picosecond-level precision, there shouldn’t be an issue. |
Beta Was this translation helpful? Give feedback.
-
There hasn’t been any activity here for four weeks. If no activity occurs over the next week, this issue will be closed as stale. |
Beta Was this translation helpful? Give feedback.
-
@patrickmichalik How would you represent a millisecond (or second) -based timestamp as a whole number that can be safely converted to a float? See for example this playground where we create two LocalDateTime objects ~1 second apart and still end up with the same float. import java.time.Instant
import kotlin.test.*
import java.time.LocalDateTime
import java.time.ZoneId
fun main(args: Array<String>) {
val localDateTime = LocalDateTime.now()
Thread.sleep(1_000)
val localDateTime2 = LocalDateTime.now()
val instant = localDateTime.atZone(ZoneId.systemDefault()).toInstant()
val instant2 = localDateTime2.atZone(ZoneId.systemDefault()).toInstant()
val milliseconds = instant.toEpochMilli()
val milliseconds2 = instant2.toEpochMilli()
val floatRepresentation = milliseconds.toFloat()
val floatRepresentation2 = milliseconds2.toFloat()
val floatToDate = LocalDateTime.ofInstant(Instant.ofEpochMilli(floatRepresentation.toLong()), ZoneId.systemDefault())
val floatToDate2 = LocalDateTime.ofInstant(Instant.ofEpochMilli(floatRepresentation2.toLong()), ZoneId.systemDefault())
println("LocalDateTime: $localDateTime")
println("LocalDateTime2: $localDateTime2")
println("Float Representation: $floatRepresentation")
println("Float Representation2: $floatRepresentation2")
println("Float as LocalDateTime: $floatToDate")
println("Float as LocalDateTime 2: $floatToDate2")
} Output:
|
Beta Was this translation helpful? Give feedback.
-
It looks like I made a mistake in my previous comment. I apologize. While We will be switching from |
Beta Was this translation helpful? Give feedback.
-
@patrickmichalik Personally I need precision down to the second with a range over a year. But if Vico 2 switches to using |
Beta Was this translation helpful? Give feedback.
-
Got it, @OskarPersson. That said, I’d suggest double-checking if such a level of precision is required. Even if we assume that two points are discernable when they’re just a pixel apart, this gives us over 31.5 million pixels—more than two kilometers on the average screen. Scrolling through such an amount of chart content would take a significant amount of time. Additionally, Compose’s |
Beta Was this translation helpful? Give feedback.
-
Vico 2.0.0-alpha.24 uses |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
All reactions