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.
- get touch location
- get axis data from touch location like this
- 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?
- jay han asked 3 months ago
- You must login to post comments
Hi,
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)
}
}
- Sanam Kapadia answered 2 months ago
- last edited 2 months ago
- You must login to post comments
Please login first to submit.