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



I need to know the position of mouse click in axes coordinates. I’ve created a modifier for this:

public class CustomPointSelectionModifier : SeriesSelectionModifier
    public override void OnModifierMouseUp(ModifierMouseArgs e)
        var xcalc = ParentSurface.XAxes.First().GetCurrentCoordinateCalculator();
        var ycalc = ParentSurface.YAxes.First().GetCurrentCoordinateCalculator();
        var poistionPoint = Mouse.GetPosition((IInputElement)ParentSurface);

        var point = new Point()
            X = xcalc.GetDataValue(poistionPoint.X),
            Y = ycalc.GetDataValue(poistionPoint.Y),
        ((SciChartMvvmBindingsViewModel)DataContext).OnMouseUp(e, point);

And it works well if axes width is zero. Otherwise, it provides values shifted by axes width (or height for Y-axis)
In my example, it should add an arrow annotation in a click point. Instead of this, it adds an arrow with shifted coordinates.

What am I doing wrong?

  • You must to post comments

Hi Alex,

Only thing you’re doing wrong is not finding the related questions on this topic!

They are:


There is also documentation on this topic here:

Axis APIs – Convert Pixel to Data Coordinates

Transforming Pixels to the Inner Viewport
Given a SciChartSurface with Axis on the left, a mouse-coordinate relative to the SciChartSurface must be transformed relative to the viewport (the central area) before the CoordinateCalculator API can be used. To do this, use the following code.

var sciChartSurface = new SciChartSurface();
  sciChartSurface.PreviewMouseDown += (s,e) =>
         // The mouse-point relative to the SciChartSurface
         Point xy = e.GetPosition(sciChartSurface);
         // Translates the mouse point (from root grid coords) to ModifierSurface coords
         Point x1y1 = sciChartSurface.RootGrid.TranslatePoint(xy, sciChartSurface.ModifierSurface);
         // you can now use this coordinate to convert to data values
         double dataValue = sciChartSurface.XAxis.GetCurrentCoordinateCalculator()

Let me know if this helps,

Best regards,

  • You must to post comments

It works!! Thank you very much!!

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.