You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have created a draggable LineChartView (only on the xAxis). I have been trying to have a snap to position (chart should automatically snap to the closest x value to center when scrolling ends) functionality similar to UICollectionView with paging enabled.
Tried implementing the chartViewDidEndPanning delegate method and using highestVisibleX to somehow get the value closest to center but it doesn't behave as expected when scrolling fast.
Is there a better way to achieve this functionality?
I managed to fix this issue myself by using DispatchQueue and a delay of 0.75 seconds. The downside of this is that the update is only triggered after 0.75 seconds; the upside is that it is accurate.
func chartViewDidEndPanning(_ chartView: ChartViewBase) { // when panning is stopped, print lowest and highest visible X DispatchQueue.main.asyncAfter(deadline: .now() + 0.75) { [self] in print(parent.chartView.lowestVisibleX.rounded()) print(parent.lineChart.highestVisibleX.rounded()) } }
What did you do?
I have created a draggable LineChartView (only on the xAxis). I have been trying to have a snap to position (chart should automatically snap to the closest x value to center when scrolling ends) functionality similar to UICollectionView with paging enabled.
Tried implementing the
chartViewDidEndPanning
delegate method and usinghighestVisibleX
to somehow get the value closest to center but it doesn't behave as expected when scrolling fast.Is there a better way to achieve this functionality?
Charts Environment
Charts version/Branch/Commit Number: 3.3.0 / master
Xcode version: 10.2.1
Swift version: 5
Platform(s) running Charts: iOS
macOS version running Xcode: 10.14.5
The text was updated successfully, but these errors were encountered: