Pre loader

how to get correct coordinate in axis?

Welcome to the SciChart Forums!

  • Please read our Question Asking Guidelines for how to format a good question
  • Some reputation is required to post answers. Get up-voted to avoid the spam filter!
  • We welcome community answers and upvotes. Every Q&A improves SciChart for everyone

WPF Forums | JavaScript Forums | Android Forums | iOS Forums


I’m developing chart with sci chart. And I current make candle stick chart.

I want to get correct center coordinate from user’s touch location.

so, I tried this way.

  1. get touch location
  2. get axis data from touch location like this
  3. get coordinate from data

let location = gestureRecognizer.location(in: self) // type is CGPoint
let selectedDate = xAxis.getDataValue(Float(location.x)) // xAxis's type is ISCIAxis
let selectedPoint = xAxis.getCoordinate(selectedData)

If I do that, no matter how far to the right you touch from the center line of the candlestick, you will get the position of the left candlestick.

If the candlestick center line is not crossed, the left data is unconditionally obtained.

I want to get the data closest to the touch, how do I do that?

  • You must to post comments

Can you please clarify what exactly you want to extract ?

  • case1 : Do you want coordinates only when the user touches the centre line?
  • case2 :Do you want nearby centre line coordinates when the user is anywhere on the surface?

For Case 1, you can refer below code.

@objc fileprivate func handleSingleTap(_ recognizer: UITapGestureRecognizer) {
        let location = recognizer.location(in: recognizer.view!.superview)
        let hitTestPoint = surface.translate(location, hitTestable: surface.renderableSeriesArea)

        let hitTestInfo = SCIHitTestInfo()
        let rSeries = surface.renderableSeries[0]
        rSeries.hitTest(hitTestInfo, at: hitTestPoint)

        if hitTestInfo.isHit {
            var coordinates = String(format: "Touch at: (%.0f, %.0f)", hitTestPoint.x, hitTestPoint.y)
            print("coordinates ==", coordinates)
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.