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!
- Ilija Kocev asked 6 years ago
- last edited 6 years ago
- You must login 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,
Yura
- Yura Khariton answered 6 years ago
-
Yes, it works great and solves my problem. Thank you very much!
- You must login to post comments
Please login first to submit.