I have troubles with the library and i can't find a solution, hope you can help.
When I put data on the chart everything about drawing axis and shapes goes well but the labels on my xAxis multiplies itself and i don't know why, look i let you my code and a problem's picture, maybe it sounds weird but in order to show the problem i created a barChart with just one data.
func setChart(values: [Double]) {
let formato:BarChartFormatter = BarChartFormatter()
formato.setArray(self.listadoLabels)
let xaxis:XAxis = XAxis()
max = values.maxElement()
barChartView.noDataText = "You need to provide data for the chart."
var dataEntries: [BarChartDataEntry] = []
for i in 0..<values.count {
let dataEntry = BarChartDataEntry(x: Double(i), y:values[i])
dataEntries.append(dataEntry)
formato.stringForValue(Double(i), axis: xaxis)
}
xaxis.valueFormatter = formato
let chartDataSet = BarChartDataSet(values: dataEntries, label: "Units Sold")
chartDataSet.colors = ChartColorTemplates.joyful()
barChartView.fitBars = true //Para que las barras inicial y final se muestren completas
barChartView.xAxis.valueFormatter = xaxis.valueFormatter
barChartView.xAxis.labelPosition = .Bottom
barChartView.leftAxis.axisMinimum = 0
barChartView.leftAxis.axisMaximum = max + 2
barChartView.rightAxis.enabled = false
barChartView.drawValueAboveBarEnabled = false
barChartView.descriptionText = ""
barChartView.xAxis.drawGridLinesEnabled = false
barChartView.animate(xAxisDuration: 1.0, yAxisDuration: 1.0)
let chartData = BarChartData()
chartData.addDataSet(chartDataSet)
barChartView.data = chartData
}
Most of code is just styling, and i have one class for the xAxis format because you need one to put labels in the xAxis, this is the code:
public func stringForValue(value: Double, axis: AxisBase?) -> String {
return "Label1"
}
I'm just sending one value of 5512, and the result is, don't pay attention to segmentTab and button: