windowsforms-devexpress-dot-xtracharts-dot-chartcontrol-ed2862c6.md
Occurs when an end-user zooms in or out of the ChartControl.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.UI.dll
NuGet Package : DevExpress.Win.Charts
public event ChartZoomEventHandler Zoom
Public Event Zoom As ChartZoomEventHandler
The Zoom event's data class is ChartZoomEventArgs. The following properties provide information specific to this event:
| Property | Description |
|---|---|
| AxisX | Gets the X-axis of the diagram point. |
| AxisY | Gets the Y-axis of the diagram point. |
| NewXRange | Gets the new value of the AxisBase.VisualRange property for the X-axis. |
| NewYRange | Gets the new value of the AxisBase.VisualRange property for the Y-axis. |
| OldXRange | Gets the old value of the AxisBase.VisualRange property for the X-axis. |
| OldYRange | Gets the old value of the AxisBase.VisualRange property for the Y-axis. |
| Type | Gets the zoom type. |
Note that this event is raised for 2D Charts only. In 3D Charts, the similar ChartControl.Zoom3D event is raised.
Note
In the Zoom event handler, you cannot change the layout of a chart. For example, modifying the ChartControl.Series or Series.Points collection in this event may affect the axis range.
This example shows how to adjust the secondary Y- axis range along which the chart is zoomed.
To accomplish this task, obtain the secondary Y-axis in the ChartControl.Zoom event handler and specify a custom secondary Y-axis range by calling the Range.SetMinMaxValues method.
using System;
using System.Windows.Forms;
using DevExpress.XtraCharts;
namespace UsingZoomEvent {
public partial class Form1 : Form {
public Form1() {
InitializeComponent();
}
private void chartControl1_Zoom(object sender, ChartZoomEventArgs e) {
ChartControl chart = (ChartControl)sender;
XYDiagram diagram = (XYDiagram)chart.Diagram;
diagram.SecondaryAxesY[0].VisualRange.SetMinMaxValues(Convert.ToDouble(e.NewYRange.MinValue) / 2,
Convert.ToDouble(e.NewYRange.MaxValue));
}
}
}
Imports Microsoft.VisualBasic
Imports System
Imports System.Windows.Forms
Imports DevExpress.XtraCharts
Namespace UsingZoomEvent
Partial Public Class Form1
Inherits Form
Public Sub New()
InitializeComponent()
End Sub
Private Sub chartControl1_Zoom(ByVal sender As Object, ByVal e As ChartZoomEventArgs) Handles chartControl1.Zoom
Dim chart As ChartControl = CType(sender, ChartControl)
Dim diagram As XYDiagram = CType(chart.Diagram, XYDiagram)
diagram.SecondaryAxesY(0).VisualRange.SetMinMaxValues(Convert.ToDouble(e.NewYRange.MinValue) / 2, Convert.ToDouble(e.NewYRange.MaxValue))
End Sub
End Class
End Namespace
See Also