SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, iOS Chart, Android Chart and JavaScript Chart Components

0
0

Hello

Is it possible do detect taps/selection/click over Axis Titles?

Thanks!

Version
4
Images
  • You must to post comments
0
0

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.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.