Pre loader

Current y value of annotation

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

How to get current Y value of annotation in code behind?

enter image description here

Version
4.1.1.8645
  • You must to post comments
1
0

Thanks for the additional info! OK so you want to get the Intercept of the VerticalLineAnnotation with a series, is that right?

In that case you need to use our Hit-Test API.

Some code like this should do it:

        // Starting with the X value of the VerticalLineAnnotaiton
        double x1 = verticalLineAnnotation.X1;
        // Perform a VerticalSliceHitTest on the series. Also see .HitTest() method for X,Y hit-tests whereas VerticalSliceHitTest considers X
        HitTestInfo hitTestResult = renderableLineSeries.VerticalSliceHitTest(new Point(x1, 0));
        // Now you have the X,Y value of the series at the hit test site
        double xValueAtHit = (double)hitTestResult.XValue;
        double yValueAtHit = (double)hitTestResult.YValue;
        // And the screen coord
        Point xyCoordAtHit = hitTestResult.HitTestPoint;

Best regards,
Andrew

  • Roland D
    Is it possible to use this with VerticalLineAnnotationViewModel? If I pass in my X1 position from a custom class based on VerticalLineAnnotationViewModel the VerticalSliceHitTest detects no hit at all. The solution below is not suitable for me because I’m working on unsorted data so ‘SearchMode.Nearest’ won’t work for FindIndex().
  • You must to post comments
1
0

I found solution:

 var dataseries = this.ParentSurface.RenderableSeries[0].DataSeries;
        var index = dataseries.FindIndex(MainAnnotation.X1, SciChart.Charting.Common.Extensions.SearchMode.Nearest);
        var yValue = (IComparable)this.ParentSurface.RenderableSeries[0].DataSeries.YValues[index];
  • You must to post comments
Showing 2 results
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