Skip to main content
A newer version of this page is available. .

ChartControl.Zoom Event

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

Namespace: DevExpress.XtraCharts

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

Declaration

public event ChartZoomEventHandler Zoom

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.

Example

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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Zoom event.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also