Completed
Last Updated: 08 Apr 2019 14:48 by Dimitar
Release R2 2019 (LIB 2019.1.415)
Ian
Created on: 01 Mar 2019 11:34
Category: UI for WinForms
Type: Bug Report
1
RadChartView: After setting the PanZoomMode property of the ChartPanZoomController to Both, the Zoom gesture results in an exception

The issue can be reproduced on a touch device after performing zoom in and zoom out

ChartPanZoomController panZoomController = new ChartPanZoomController();
panZoomController.PanZoomMode = ChartPanZoomMode.Both;
this.radChartView1.Controllers.Add(panZoomController);

 


3 comments
Dimitar
Posted on: 08 Apr 2019 14:48
Hello, 
 
A Fix will be available in LIB Version 2019.1.415 scheduled for April 15th.

Regards,
Dimitar
ADMIN
Hristo
Posted on: 05 Mar 2019 07:32
Hi,

Just a quick update that the same error can be observed while zooming on the vertical axis. The custom implementation below also handles zooming on both axes: 
public partial class Form2 : Form
{
    public Form2()
    {
        InitializeComponent();
 
        LineSeries series = new LineSeries();
        for (int i = 0; i < 10; i++)
        {
            series.DataPoints.Add(new CategoricalDataPoint(i, "Point " + i));
        }
 
        this.radChartView1.Controllers.Add(new MyChartPanZoomController() { PanZoomMode = ChartPanZoomMode.Both });
 
        this.radChartView1.Series.Add(series);
    }
}
 
public class MyChartPanZoomController : ChartPanZoomController
{
    private double currentZoom = 1d;
 
    protected override ActionResult OnRotateGesture(Telerik.WinControls.RotateGestureEventArgs args)
    {
        return Controller.Empty;
    }
 
    protected override ActionResult OnZoomGesture(ZoomGestureEventArgs args)
    {
        if (args.ZoomFactor == 1.0)
        {
            args.Handled = true;
 
            return Controller.Empty;
        }
 
        this.currentZoom *= args.ZoomFactor;
        if (this.currentZoom < 1d)
        {
            this.currentZoom = 1d;
        }
        else if (this.currentZoom > 100)
        {
            this.currentZoom = 100d;
        }
 
        if (this.Area is PieArea && this.Area.Series.Count > 0)
        {
            PieSeries series = this.Area.Series[0] as PieSeries;
 
            foreach (PieDataPoint point in series.DataPoints)
            {
                double offset = point.OffsetFromCenter + 1.0;
                if (offset <= 1.0)
                {
                    offset = 1.0;
                }
 
                offset = offset * args.ZoomFactor;
 
                if (offset > 2.0)
                {
                    offset = 2.0;
                }
 
                if (offset < 1.0)
                {
                    offset = 1.0;
                }
 
                point.OffsetFromCenter = offset - 1.0;
            }
        }
        else
        {
            double zoomWidth = ((IChartView)this.Area.View).ZoomWidth;
            double zoomHeight = ((IChartView)this.Area.View).ZoomHeight;
 
            double newHorizontalScaleFactor = 0;
            double newVerticalScaleFactor = 0;
 
            newHorizontalScaleFactor = zoomHeight * this.currentZoom;
            newVerticalScaleFactor = zoomWidth * this.currentZoom;
 
            if (args.ZoomFactor > 1)
            {
                newHorizontalScaleFactor = zoomHeight * this.currentZoom;
                newVerticalScaleFactor = zoomWidth * this.currentZoom;
            }
            else
            {
                newHorizontalScaleFactor = zoomHeight / this.currentZoom;
                newVerticalScaleFactor = zoomWidth / this.currentZoom;
            }
 
 
            newHorizontalScaleFactor = this.ClampValue(newHorizontalScaleFactor, 1, 100);
            newVerticalScaleFactor = this.ClampValue(newVerticalScaleFactor, 1, 100);
 
            switch (this.PanZoomMode)
            {
 
                case ChartPanZoomMode.Horizontal:
                    this.Area.View.Zoom(newHorizontalScaleFactor, zoomHeight);
                    break;
                case ChartPanZoomMode.Vertical:
                    this.Area.View.Zoom(zoomWidth, newVerticalScaleFactor);
                    break;
                case ChartPanZoomMode.Both:
                    this.Area.View.Zoom(newHorizontalScaleFactor, newVerticalScaleFactor);
                    break;
            }
        }
 
        args.Handled = true;
 
        return Controller.Empty;
    }
 
    private double ClampValue(double value, double minValue, double maxValue)
    {
        return Math.Max(minValue, Math.Min(value, maxValue));
    }
}

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
ADMIN
Hristo
Posted on: 01 Mar 2019 11:38
Hello,

Currently, there is no suitable workaround. If possible consider zooming along the horizontal or vertical axis only.

Regards,
Hristo
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.