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


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:

Help please!

  • You must to post comments

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,

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