Pre loader

ChartModifierBase OnModifierMouseDown reports coordinates incorrectly

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 guys,

After adding a YAxis to the left of my SciChart I’ve noticed that this code no longer functions as I expect:

        public override void OnModifierMouseDown(ModifierMouseArgs e)

            if (ParentSurface.RenderableSeries.First().XAxis == null)

            if (!_mouseDragged && IsFunctional)
                _mouseDragged = true;
                _selectionStart = (DateTime) ParentSurface.RenderableSeries.First().HitTest(e.MousePoint).XValue;

_selectionStart should be a Date under the cursor where the user has just clicked. Instead it’s a Date approx. 40pixels to the right of where the user has just clicked because the Left YAxis is approx. 40 pixels, and the ModifierMouseArgs.MousePoint is considering the YAxis space into it’s X coordinate value.

So when I take that point and perform a HitTest, I am not getting the expected result here.

I will write a fix for this to take into account a Left Y Axis if one exists and modify the point’s X coordinate value, but I thought to give you a heads-up in case this is outside of expected functionality and is indeed a bug.


  • You must to post comments
Best Answer

Hi Miles,

This is because all mouse clicks are relative to the parent SciChartsurface. If you want to get the coordinates relative to the ModifierSurface itself, you have to perform a simple translation operation.

public override void OnModifierMouseMove(ModifierMouseArgs e)
   // gets the bounds of the ModifierSurface with respect to the RootGrid
   // which hosts the SciChartSurface
   var modifierRect = ModifierSurface.GetBoundsRelativeTo(RootGrid);

   // Translates the mouse point (from root grid coords) to ModifierSurface coords
   var mousePoint = base.GetPointRelativeTo(e.MousePoint, ModifierSurface);

Can you try the above translation and let me know if it works?

  • bstapylton
    Hi Andrew, This translation using GetPointRelativeTo works perfectly. Thank you and bravo, Miles
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.