Scroll Position, getting X axis values for current scroll position #788
Replies: 2 comments 1 reply
-
Hello, @BarabasIstvanAttila. We plan on making
If you're using |
Beta Was this translation helpful? Give feedback.
-
Thank you @Gowsky for answering. We are using CartesianChartModelProducer. We have an Horizontal Axis and the setup is the following:
We have ended up using a snapshotFlow to check when scroll has ended:
and calculate back from the last scroll value what that value represents:
|
Beta Was this translation helpful? Give feedback.
-
Question
When enabling scroll on a line chart, I need to take the visible elements on the chart. Lets say I have multiple months of data points and I am showing only one week at a time, how can I get the window of what is visible. I have tried scrollState but it is returning pixels, and also I have tried to listen for the updates of the X axis CartesianValueFormatter, but it is not accurate. Any suggestions?
Edit:
One possible solution was to listen to scroll updates:
snapshotFlow { scrollState.value }
And transform the pixel position of the scroll to an x position on x-axis
val scrollStep = maxScroll / (max_x - min_x)
Vico version(s)
2.0.0-alpha.21
UI framework(s)
Jetpack Compose
Beta Was this translation helpful? Give feedback.
All reactions