Pre loader

Panning/Dragging on Y axis is moving X axis also

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

0
0

Hello, I have added YAxisDragModifier and ZoomPanModifier to my surface and when I try to drag on Y axis I can move the X axis too and that is not the behavior that I was trying to get. I want when I drag/move YAxis not to move on the YAxis also.

Here is my code:

Surface.ChartModifiers.Add(new PinchZoomModifier());
Surface.ChartModifiers.Add(new ZoomExtentsModifier());
Surface.ChartModifiers.Add(new YAxisDragModifier { DragMode = AxisDragModifierBase.AxisDragMode.Pan });
Surface.ChartModifiers.Add(new XAxisDragModifier { DragMode = AxisDragModifierBase.AxisDragMode.Pan, ClipModeX = ClipMode.None });
Surface.ChartModifiers.Add(new ZoomPanModifier
{
Direction = Direction2D.XDirection,
ZoomExtentsY = false
});

Here is the video with the behavior:
VIDEO: https://drive.google.com/file/d/1kbYi2voKNvHD5J7D6-XDw7OJx4IwlEqr/view

Help please!

Version
2.2.2.866
  • You must to post comments
0
0

Hi Ilija,

Well this is default behavior for YAxisDragModifier. If don’t want scroll to work outside axis then you’ll need to extend YAxisDragModifier and override few methods and don’t perform pan/scale on axis if current point is outside axis bounds:

class CustomYAxisDragModifier : YAxisDragModifier
{
    private float _currentX, _currentY;

    public override bool OnScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
    {
        _currentX = e2.GetX();
        _currentY = e2.GetY();

        return base.OnScroll(e1, e2, distanceX, distanceY);
    }

    protected override void PerformPan(float xDelta, float yDelta, bool isSecondHalf, IAxis axis)
    {
        if(axis.IsPointWithinBounds(_currentX, _currentY, ParentSurface))
            base.PerformPan(xDelta, yDelta, isSecondHalf, axis);
    }

    protected override void PerformScale(float xDelta, float yDelta, bool isSecondHalf, IAxis axis)
    {
        if(axis.IsPointWithinBounds(_currentX, _currentY, ParentSurface))
            base.PerformScale(xDelta, yDelta, isSecondHalf, axis);
    }
}

Is this suitable for your needs?

Hope this will help you!

Best regards,
Yura

  • Ilija Kocev
    Yes, it works great and solves my problem. Thank you very much!
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.

Try SciChart Today

Start a trial and discover why we are the choice
of demanding developers worldwide

Start TrialCase Studies