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/
- Mohani Bhaskar asked 4 years ago
- You must login to post comments
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
- Andrew Burnett-Thompson answered 4 years ago
- You must login to post comments
Please login first to submit.