ios-chartsswift3.2

IOS Charts - Limit Line appears twice after refreshing data


I'm using iOS Charts by Daniel Gindi on Github. I'm presenting a chart with a Limit Line and all is well. When I add data to the chart, everything is working fine, yet the Limit Line appears twice. I've tried reinitializing the Limit Line:

    var limitLine = ChartLimitLine()
    limitLine = ChartLimitLine(limit: 
    self.averagePointsArray.average, label: "This weeks average")
    self.barChartView.rightAxis.addLimitLine(limitLine)
    self.setChart()

I've also tried to use the methods:

barChartView.clear() barChartView.clearValues()

Again, the data is chart is working fine. Strange.

enter image description here


Solution

  • The documentation on iOS Charts is rather scarce as it was ported from an Android library (which is fully documented)

    I came across this method that enables the removal of the Limit Line

    barChartView.rightAxis.removeLimitLine(self.limitLine)
    

    I remove it and add it back with the updated Limit Line value.