The issue can be reproduced on a touch device after performing zoom in and zoom out
ChartPanZoomController panZoomController = new ChartPanZoomController();
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));
}
}