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

Answered
4
0

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)
        {
            base.OnModifierMouseDown(e);

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

            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.

Cheers,
Miles

  • You must to post comments
Best Answer
4
0

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?

Images
  • 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.