Search code examples
swiftios-charts

Coordinates of a point - ios-charts [Swift]


I searched in the library for two days and unfortunately I'm not able to find out how to get the space between two data in px. My linechartview is contained in a UIScrollView and the aim is to get the value of the linechartview point which is located in the center of ScrollView.


Solution

  • Normally, it has a transfomer to convert data value to px value like:

    position.x = CGFloat(i) // index on x axis, like 0,1,2
    position.y = 0.0
    position = CGPointApplyAffineTransform(position, valueToPixelMatrix)
    

    Above code is taken from internal func drawLabels, at which you should take a look

    After this position will be the px. value on the screen. You just need to figure out how you get it and pass to your other functions, like using a delegate