Hello
Is it possible do detect taps/selection/click over Axis Titles?
Thanks!
- Rodrigo Garcia asked 3 years ago
- You must login to post comments
Hi, there.
Currently, we do not support such functionality. Please, consider creating a feature request and we will prioritize this task for future releases.
What you can do as a workaround is this:
– create a custom tap gesture modifier
– find your axis title attributed string frame relative to the surface
– check if this frame contains tap location.
Here is some prototype code. Please, note that I took “boundingRect” function to get attributed string frame I’ve got from here:
class AxisTapModifier: SCIGestureModifierBase {
override func createGestureRecognizer() -> SCIGestureRecognizer {
SCITapGestureRecognizer()
}
override func onGestureEnded(with args: SCIGestureModifierEventArgs) {
print("onGestureEnded")
guard
let surface = parentSurface?.adornerLayer.view
else { return }
let titleSize = "Axis title".boundingRect(with: surface.view.frame.size, font: .systemFont(ofSize: 20), lines: 1)
let hitFrame = CGRect(
x: surface.view.frame.midX - titleSize.width / 2,
y: surface.view.frame.maxY - titleSize.height,
width: titleSize.width,
height: titleSize.height
)
let isHit = hitFrame.contains(args.location)
print("isHit: \(isHit)")
}
}
// configure your surface
xAxis.axisTitle = “Axis title”
xAxis.titleStyle = SCIFontStyle(fontSize: 20, andTextColor: .red)
self.surface.chartModifiers.add(AxisTapModifier())
Let us know if it helps.
- Andriy P answered 3 years ago
- You must login to post comments
Please login first to submit.