ChartControl.Zoom Event

Occurs when an end-user zooms in or out of the ChartControl.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.UI.dll

Declaration

public event ChartZoomEventHandler Zoom
Public Event Zoom As ChartZoomEventHandler

Event Data

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.
NewAxisXRange Obsolete. Gets the new value of the AxisBase.Range property for the X-axis.
NewAxisYRange Obsolete. Gets the new value of the AxisBase.Range property for the Y-axis.
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.
OldAxisXRange Obsolete. Gets the old value of the AxisBase.Range property for the X-axis.
OldAxisYRange Obsolete. Gets the old value of the AxisBase.Range 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.

Remarks

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.

Examples

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));
        }
    }
}
See Also