I want to display String values for X-Axis in line chart via using 'Charts'
I've followed tutorial for same here. As per wrote there
let lineChartData = LineChartData(xVals: dataPoints, dataSet: lineChartDataSet)
I'm not finding in current latest version of library.
In, current library version's demo code I'm only able to fill double
type of data for X-axis and Y-axis.
Please help me to solve this.
Here is desired output.
There's a protocol IAxisValueFormatter that you can implement and achieve your expected result.
EDIT:
How to use it
While initialising
chartView.xAxis.valueFormatter = self
and implementing protocol.
extension LineChart1ViewController: IAxisValueFormatter {
func stringForValue(_ value: Double, axis: AxisBase?) -> String {
let months = ["January","February","March","April","May","June","July","Auguest","September","October","November","December"]
return months[Int(value)]
}
}