iosswiftxcodeswiftcharts

Swiftchars - bars chart overlap after specific number of points


SwiftCharts version 0.6.5 Swift version 5


Solution

  • Finally I found solution:

    I had to set the minZoomX and maxZoomX (in chart settings) with fixed value which the number of pages for the chart (or number of scrollable area than the original width). why x ? because I want chart to scroll horizontally.

    here is code:

            let barWidth: CGFloat = 30.0
            let spaceBetweenBars: CGFloat = 80.0
    
            let zoomXValue = CGFloat(barsDataSource.count) / (UIScreen.main.bounds.width / (barWidth + spaceBetweenBars))
            chartSettings.zoomPan.minZoomX = zoomXValue
            chartSettings.zoomPan.maxZoomX = zoomXValue