Pre loader

Get the coordinate of a data point of the series in c#

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

I want to click on the data points and get the x and y co-ordinate values stored somewhere, as I further need the data point values. I have already searched for many examples and codes but I’m not able to implement this in my Windows form application (C#). There are some good examples are given on dataPoint selection but I want to use that in my c# code, can you please provide me a example of this in c# instead of xaml.
I have already referred to the below links but not able to find a solution to my problem.

https://www.scichart.com/documentation/win/current/DataPoint%20Selection.html
https://www.scichart.com/example/wpf-chart-example-pointmarkers-selection/

Version
6.0.269
  • You must to post comments
0
0

Hi Mohani

The API you need is the Hit-Test API.

If you look at the example in the Hit Test documentation it should be fairly easy to follow.

// Subscribed using this code:
// sciChartSurface.MouseLeftButtonUp += SciChartSurfaceMouseLeftButtonUp;
private void SciChartSurfaceMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{
    // Perform the hit test relative to the GridLinesPanel
    Point mousePoint = e.GetPosition(sciChartSurface.GridLinesPanel as UIElement);
    double datapointRadius = 8;
    bool useInterpolation = false;
    HitTestInfo result = sciChartSurface.RenderableSeries[0].HitTestProvider.HitTest(mousePoint,
                                      datapointRadius, useInterpolation);

    // Output results
    string formattedString =
        string.Format(
            "{6}:\tMouse Coord: {0:0}, {1:0}\t\tNearest Datapoint Coord: {2:0.0},
                                  {3:0.0}\tData Value: {4:0.0}, {5:0.0}",
            mousePoint.X, mousePoint.Y,
            result.HitTestPoint.X, result.HitTestPoint.Y,
            result.XValue, result.YValue,
            result.DataSeriesName);

    Console.WriteLine(formattedString);
}

Let me know if this helps

Best regards,
Andrew

  • 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