How to set BarChartDataEntry labels (String not Double) not xaxis labels

Hi all i need help i want to format BarChartDataEntry labels as shown in image. enter image description here

My Code

    var dataEntries: [BarChartDataEntry] = []     var dataEntriesBottom: [BarChartDataEntry] = []      for i in 0..<goals.count {         let dataEntry = BarChartDataEntry(x: Double(i), y: Double(goals[i]))        dataEntries.append(dataEntry)      }     let chartDataSet = BarChartDataSet(entries: dataEntries, label: "")     chartDataSet.colors = [.systemGreen]     let chartData = BarChartData(dataSet: chartDataSet)     chartData.barWidth = 0.4     chartView.xAxis.drawAxisLineEnabled = false     chartView.leftAxis.drawAxisLineEnabled = false     chartView.xAxis.drawGridLinesEnabled = false     chartView.rightAxis.drawAxisLineEnabled = false     chartView.leftAxis.drawLabelsEnabled = false     chartView.rightAxis.drawLabelsEnabled = false     chartView.leftAxis.drawGridLinesEnabled = false     chartView.rightAxis.drawGridLinesEnabled = false     chartView.xAxis.enabled = false     chartView.xAxis.drawLabelsEnabled = false     chartView.xAxis.granularity = 0     self.chartView.animate(yAxisDuration: 1.0)     self.chartView.legend.enabled = false     chartView.data = chartData 
Add Comment
1 Answer(s)

try something like this:

let myFormatter = NumberFormatter() myFormatter.numberStyle = .decimal myFormatter.maximumFractionDigits = 0 chartData.setValueFormatter(DefaultValueFormatter(formatter: myFormatter)) 
Answered on August 31, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.