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


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

enter image description here

  • You must to post comments

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,

  • You must to post comments

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.