I'm having an issue in displaying a simple line chart using iOS Charts
I followed this tutorial and it works.
When I try to put my data on the graph it displays correctly the grid and values on-axis, but not the line.
Here my code:
func setChartData(xLabel: [Double], yLabel: [Double]){
let values = (0..<15).map { (i) -> ChartDataEntry in
return ChartDataEntry(x: xLabel[i], y: yLabel[i])
}
let set1 = LineChartDataSet(values: values, label: "DataSet")
let data = LineChartData(dataSet: set1)
self.lineChartView.data = data
}
Then, in the viewDidLoad()
I call my function and pass it these two lists:
let x = [19.0, 18.0, 17.0, 16.0, 15.0, 14.0, 13.0, 12.0, 11.0, 10.0, 9.0, 8.0, 7.0, 6.0, 5.0]
let y = [1.5587, 1.5591999999999999, 1.5587, 1.5587, 1.5604, 1.5528, 1.5544, 1.5427, 1.5475000000000001, 1.5475000000000001, 1.5475000000000001, 1.5402, 1.5488, 1.5445, 1.5468]
The result that I obtain is like that:
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…