SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components
Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on Stackoverflow.com where you can earn rep for your questions!
Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.
I want to capture the XY coordinate related to XY axis of my scichartsurface after a MouseLeftButtonDown. At first I try this:
Point mousePoint = e.GetPosition(((SciChartSurface)sender));
but the coordinates are in pixel? instead I want my xy that are double…
Then I try this code from an example:
Point mousePoint = e.GetPosition(((SciChartSurface)sender).GridLinesPanel as UIElement);
var hitTest = ((SciChartSurface)sender).RenderableSeries.HitTest(mousePoint);
now hitTest.XValue and hitTest.YValue are the correct data of the nearest point, but I want the exactly coordinates of the point where I clicked, not the nearest. It is possible? How can I do?
Thanks for reply
you need the coordinate calculator API.
var xCalc = sciChartSurface.XAxis.GetCurrentCoordinateCalculator(); var yCalc = sciChartSurface.YAxis.GetCurrentCoordinateCalculator();
Point mousePoint = e.GetPosition(sciChartSurface.ModifierSurface as UIElement);
double xDataValue = xCalc.GetDataValue(mousePoint.X); double yDataValue = yCalc.GetDataValue(mousePoint.Y);
That should do it!
Note the coordinate calculator will transform to / from datavalues and coordinates, it is used internally by SciChart so very fast and reliable.
Hope this helps!
Please login first to submit.