Back to Devexpress

ChartZoomEventArgs.NewYRange Property

corelibraries-devexpress-dot-xtracharts-dot-chartzoomeventargs-11c27ac5.md

latest3.8 KB
Original Source

ChartZoomEventArgs.NewYRange Property

Gets the new value of the AxisBase.VisualRange property for the Y-axis.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public RangeInfo NewYRange { get; }
vb
Public ReadOnly Property NewYRange As RangeInfo

Property Value

TypeDescription
RangeInfo

A RangeInfo object which represents the new value of the axis range.

|

Remarks

Use the ChartZoomEventArgs.OldYRange and NewYRange properties to obtain the Y-axis’s AxisBase.VisualRange property values before and after a chart is zoomed in the ChartControl.Zoom event handler. For more information on zooming a chart diagram, please refer to the Zooming and Scrolling (2D XY-Charts) topic.

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.

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

ChartZoomEventArgs Class

ChartZoomEventArgs Members

DevExpress.XtraCharts Namespace