Pre loader

Detect Tap/Selection/Click over Axis Titles

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

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.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies