Completed
Last Updated: 05 Jan 2017 07:45 by ADMIN
ADMIN
Hristo
Created on: 29 Dec 2016 12:21
Category: ChartView
Type: Bug Report
1
FIX. RadChartView - disable panning of the ChartPanZoomController if you are zooming using the UI to scale factors greater than 100
Workaround: use a custom ChartPanZoomController

public class MyChartPanZoomController : ChartPanZoomController
    {
        protected override ActionResult OnMouseWheel(MouseEventArgs e)
        {
            if (!(this.Area is CartesianArea))
            {
                return base.OnMouseWheel(e);
            }

            if ((Control.ModifierKeys & Keys.Control) == Keys.Control)
            {
                IChartView chartView = this.Area.View;

                double zoomWidth = chartView.ZoomWidth;

                if (this.PanZoomMode == ChartPanZoomMode.Horizontal || this.PanZoomMode == ChartPanZoomMode.Both)
                {
                    zoomWidth += ((double)e.Delta / 1200d);
                }

                double zoomHeight = chartView.ZoomHeight;

                if (this.PanZoomMode == ChartPanZoomMode.Vertical || this.PanZoomMode == ChartPanZoomMode.Both)
                {
                    zoomHeight += ((double)e.Delta / 1200d);
                }

                zoomWidth = this.ClampValue(zoomWidth, 1d, 100d);
                zoomHeight = this.ClampValue(zoomHeight, 1d, 100d);

                double virtualHorizontalPosition = e.X - this.Area.AreaModel.LayoutSlot.X - chartView.PlotOriginX;
                double plotAreaVirtualWidth = this.Area.AreaModel.LayoutSlot.Width * chartView.ZoomWidth;
                double relativeHorizontalPosition = virtualHorizontalPosition / plotAreaVirtualWidth;
                double newPlotAreaVirtualWidth = this.Area.AreaModel.LayoutSlot.Width * zoomWidth;
                double newPanOffsetX = (newPlotAreaVirtualWidth * relativeHorizontalPosition) - (e.X - this.Area.AreaModel.LayoutSlot.X);
                newPanOffsetX = this.ClampValue(newPanOffsetX, 0, this.Area.AreaModel.LayoutSlot.Width * (zoomWidth - 1d));

                double virtualVerticalPosition = e.Y - this.Area.AreaModel.LayoutSlot.Y - chartView.PlotOriginY;
                double plotAreaVirtualHeight = this.Area.AreaModel.LayoutSlot.Height * chartView.ZoomHeight;
                double relativeVerticalPosition = virtualVerticalPosition / plotAreaVirtualHeight;
                double newPlotAreaVirtualHeight = this.Area.AreaModel.LayoutSlot.Height * zoomHeight;
                double newPanOffsetY = (newPlotAreaVirtualHeight * relativeVerticalPosition) - (e.Y - this.Area.AreaModel.LayoutSlot.Y);
                newPanOffsetY = this.ClampValue(newPanOffsetY, 0, this.Area.AreaModel.LayoutSlot.Height * (zoomHeight - 1d));

                this.Area.View.Zoom(zoomWidth, zoomHeight);
                this.Area.View.Pan(-newPanOffsetX, -newPanOffsetY);
            }

            return Controller.Empty;
        }

        private double ClampValue(double value, double minValue, double maxValue)
        {
            return Math.Max(minValue, Math.Min(value, maxValue));
        }
    }
0 comments