Back to Devexpress

AxisScaleChangedEventArgs.Axis Property

corelibraries-devexpress-dot-xtracharts-dot-axisscalechangedeventargs.md

latest3.5 KB
Original Source

AxisScaleChangedEventArgs.Axis Property

Returns the axis whose scale mode, measure unit, grid alignment or grid spacing has been changed.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public AxisBase Axis { get; }
vb
Public ReadOnly Property Axis As AxisBase

Property Value

TypeDescription
AxisBase

The axis whose scale parameters have been changed.

|

Example

Use the ChartControl.AxisScaleChanged (WebChartControl.AxisScaleChanged) event to obtain the axis‘ automatically calculated grid alignment and measurement unit values, when the scale mode is automatic. Moreover the event arguments contains the axis itself. This event is raised when the scale mode, measure unit, grid alignment or grid spacing of the axis scale has been changed.

csharp
private void Form1_Load(object sender, EventArgs e) {
    chartControl1.AxisScaleChanged += OnChartAxisScaleChanged;
}

private void OnChartAxisScaleChanged(object sender, AxisScaleChangedEventArgs e) {
    AxisX axisX = e.Axis as AxisX;
    if (axisX == null) return;
    // In this event, you can access the properties of the corresponding axis, and
    // obtain the automatically calculated value for the axis date-time grid alignment and measure unit.
    axisX.Title.Visibility = DefaultBoolean.True;
    axisX.Title.Text = String.Format(
        "The Axis Grid Alignment Unit is {0} \r\nThe Axis Measure Unit is {1}", 
        e.Axis.DateTimeScaleOptions.GridAlignment.ToString(),
        e.Axis.DateTimeScaleOptions.MeasureUnit.ToString()
    );
}
vb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    AddHandler chartControl1.AxisScaleChanged, AddressOf OnChartAxisScaleChanged
End Sub

Private Sub OnChartAxisScaleChanged(ByVal sender As Object, ByVal e As AxisScaleChangedEventArgs)
    Dim axisX As AxisX = TryCast(e.Axis, AxisX)
    If axisX Is Nothing Then
        Return
    End If
    ' In this event, you can access the properties of the corresponding axis, and
    ' obtain the automatically calculated value for the axis date-time grid alignment and measure unit.
    axisX.Title.Visibility = DefaultBoolean.True
    axisX.Title.Text = String.Format("The Axis Grid Alignment Unit is {0} " & ControlChars.CrLf & "The Axis Measure Unit is {1}", e.Axis.DateTimeScaleOptions.GridAlignment.ToString(), e.Axis.DateTimeScaleOptions.MeasureUnit.ToString())
End Sub

See Also

AxisScaleChangedEventArgs Class

AxisScaleChangedEventArgs Members

DevExpress.XtraCharts Namespace