Pre loader

How Get XY coordinates of SciChartSurface?

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


Hi all,
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[0].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 must to post comments

Hello Tony,

you need the coordinate calculator API.

  1. Get a Coordinate Calculator instance (per axis, valid per render pass and only once drawn)
var xCalc = sciChartSurface.XAxis.GetCurrentCoordinateCalculator();
var yCalc = sciChartSurface.YAxis.GetCurrentCoordinateCalculator();
  1. Transform your pixel coordinates relative to the main render area (where gridlines and series are drawn)
Point mousePoint = e.GetPosition(sciChartSurface.ModifierSurface as UIElement);
  1. Use the coordinate Calculators to convert to/from data values!
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!


  • 10tony89
    Hi Andrew, the code that you have post work correctly for X coordinate, but not for the Y. You make a little mistake for the y, double yDataValue = xCalc.GetDataValue(mousePoint.Y); You should replace xCalc with yCalc so everything work fine. Thanks a lot! Bye
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.