I want to use iOS-Charts with Swift to draw some line charts to show the data. Now, I have a requirement that put a small icon beside each point.
Now I can add UIImage on the graph, but the problem is how can I get the CGPoint coordinates of each points correctly.
If I change the orientation of device or device type, the position of images are still fixed, not change correspondingly. Here is iPhone 6s picture.
Here is my current code:
for i in 0..<dataPoints.count {
let pointLeft = lineChartView.getPosition(dataEntries[i], axis: .Left)
let image = UIImage(named: numbers[i])
let imageView = UIImageView(image:image!)
imageView.frame = CGRect(x: pointLeft.x, y: pointLeft.y, width: 16, height: 16)
lineChartView.addSubview(imageView)
}