Replies: 2 comments 2 replies
-
|
You can create a line chart with a time-based x-axis. User interaction can be done in the regular Compose way, by updating state variables which would update the x-axis time range, for example. The video is showing horizontal scrolling, which is only available on Android if the user pinch-zooms first. It might work on iOS too if Compose uses the same gesture controls but I don't have iOS devices to confirm. I know it doesn't work on Desktop or browser because Compose doesn't support the gestures on those platforms (last time I checked). |
Beta Was this translation helpful? Give feedback.
-
|
User zooming for both x and y axes works for me on the Android emulator. I hadn't considered the use case of programmatically changing the zoom vs only through the user interface. The axis doesn't use a mutable state internally, so to have a zoom change cause a recomposition you should create a new axis model to cause recomposition. For example, store the axis model in a mutable state, and when the user chooses a new zoom factor create a new axis model with a zoom factor corresponding to what the user chose, and then update it in the mutable state. This should cause a recomposition of the XYGraph with the new axis model. The panZoomEnabled boolean to XYGraph can be set to false to disable mouse-based zooming, but this will also disable panning. You can add a pointer input modifier on the XYGraph or one of the internal plots and then handle scrolling from there. An easier approach which would also benefit other users would be to split the panZoomEnabled flag into two, one for panEnabled and one for zoomEnabled, and in XYGraph control which transforms are computed based on those settings, e.g. around lines 183-184 by passing in those two flags to enable/disable computation of the pan and/or zoom changes. Would you be willing to try making that change and submitting a pull request? |
Beta Was this translation helpful? Give feedback.

Uh oh!
There was an error while loading. Please reload this page.
-
Hello. Can I use this library to create a line chart like the one in this video (x-axis: hours (timestamp), where the user can choose zoom: 3, 6, 12, or 24 hours (only preset options available to the user), with the latest value shown above the chart)?
video_2024-08-05_20-59-10.mp4
Beta Was this translation helpful? Give feedback.
All reactions