Completed
Last Updated: 10 Feb 2015 13:25 by ADMIN
ADMIN
Dimitar
Created on: 05 Dec 2014 08:22
Category: ChartView
Type: Bug Report
1
FIX. RadChartView - lasso controller does not zoom properly the vertical axis.
The lasso controller does not zoom properly the vertical axis - the interval is not correct. 

Workaround: 
public class Lasso : LassoZoomController
{
    protected override ActionResult OnMouseUp(MouseEventArgs e)
    {
        if (e.Button != MouseButtons.Left)
        {
            return base.OnMouseUp(e);
        }

        if (MouseDownLocation != MouseMoveLocation)
        {
            Point point = (Point)typeof(LassoZoomController).GetMethod("ClipLocation", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).Invoke(this, new object[] { e.Location });
            this.MouseMoveLocation = point;
            SizeF areaSize = SizeF.Empty;
            CartesianArea area = this.Area.View.GetArea<CartesianArea>();

            if (area != null)
            {
                IChartView chartView = this.Area.View;
                var temp = area.GetType().GetMethod("GetCartesianClipRect", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).Invoke(area, null);
                areaSize = ((RectangleF)temp).Size;
                double delta = this.Area.View.Viewport.Width - areaSize.Width + this.Area.View.Viewport.X;
                double start = ((this.MouseDownLocation.X - chartView.PlotOriginX - delta) / areaSize.Width / chartView.ZoomWidth) * 100;
                double end = (MouseMoveLocation.X - chartView.PlotOriginX - delta) / areaSize.Width / chartView.ZoomWidth * 100;
                double zoomFactor = 100d / Math.Abs(start - end);

                double deltaHeight = this.Area.View.Viewport.Height - areaSize.Height + this.Area.View.Viewport.Y;
                double startH = ((this.MouseDownLocation.Y - chartView.PlotOriginY - deltaHeight) / areaSize.Height / chartView.ZoomHeight) * 100;
                double endH = (MouseMoveLocation.Y - chartView.PlotOriginY - deltaHeight) / areaSize.Height / chartView.ZoomHeight * 100;
                double zoomFactorH = 100d / Math.Abs(startH - end);

                if (zoomFactor < 1d)
                {
                    zoomFactor = 1d;
                }

                if (zoomFactor > 100d)
                {
                    zoomFactor = 100d;
                }

                if (zoomFactorH < 1d)
                {
                    zoomFactorH = 1d;
                }

                if (zoomFactorH > 100d)
                {
                    zoomFactorH = 100d;
                }

                double pan = (((areaSize.Width - 1) * zoomFactor) / 100) * Math.Min(start, end);
                double panH = (((areaSize.Height - 1) * zoomFactorH) / 100) * Math.Min(startH, endH);

                this.Area.View.Zoom(zoomFactor, zoomFactorH);
                this.Area.View.Pan(-pan, -panH);
            }
        }

        ViewResult result = typeof(LassoZoomController).GetField("result", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(this) as ViewResult;
        result.ShouldInvalidate = true;


        return new ViewResult() { ShouldInvalidate = true };
    }
}
0 comments