Back to Devexpress

ChartControl.AxisScaleChanged Event

windowsforms-devexpress-dot-xtracharts-dot-chartcontrol-7d9050a0.md

latest4.6 KB
Original Source

ChartControl.AxisScaleChanged Event

Occurs when the scale mode, measure unit, grid alignment or grid spacing of the axis scale has been changed.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.UI.dll

NuGet Package : DevExpress.Win.Charts

Declaration

csharp
public event EventHandler<AxisScaleChangedEventArgs> AxisScaleChanged
vb
Public Event AxisScaleChanged As EventHandler(Of AxisScaleChangedEventArgs)

Event Data

The AxisScaleChanged event's data class is AxisScaleChangedEventArgs. The following properties provide information specific to this event:

PropertyDescription
AxisReturns the axis whose scale mode, measure unit, grid alignment or grid spacing has been changed.
GridSpacingChangeReturns information about grid spacing changes.
ScaleModeChangeReturns information about scale mode changes.

Remarks

Note that the event args type depends on the current axis scale type. The following table shows dependencies between scale types and argument types.

Scale typeArgs type
QualitativeQualitativeScaleChangedEventArgs
NumericNumericScaleChangedEventArgs
Date-TimeDateTimeScaleChangedEventArgs
Time-SpanTimeSpanScaleChangedEventArgs

For Web Charts, handle the WebChartControl.AxisScaleChanged event.

Example

Handle the ChartControl.AxisScaleChanged event to obtain the axis‘ automatically calculated grid alignment and measurement unit values when the scale mode is automatic. The event arguments also contain the axis itself. This event occurs 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) {
    this.ordersTableAdapter.Fill(this.nwindDataSet.Orders);
    this.chartControl.AxisScaleChanged += OnAxisScaleChanged;
}

private void OnAxisScaleChanged(object sender, AxisScaleChangedEventArgs e) {
    AxisX axis = e.Axis as AxisX;
    DateTimeScaleChangedEventArgs args = e as DateTimeScaleChangedEventArgs;
    if ((args == null) || (args == null)) return;
    axis.Title.Text = String.Format(
        "The Axis Grid Alignment Unit is {0}\r\nThe Axis Measure Unit is {1}", 
        args.GridAlignmentChange.NewValue,
        args.MeasureUnitChange.NewValue);
}
vb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
    Me.ordersTableAdapter.Fill(Me.nwindDataSet.Orders)
    AddHandler Me.chartControl.AxisScaleChanged, AddressOf OnAxisScaleChanged
End Sub

Private Sub OnAxisScaleChanged(ByVal sender As Object, ByVal e As AxisScaleChangedEventArgs) Handles chartControl.AxisScaleChanged
    Dim axis As AxisX = TryCast(e.Axis, AxisX)
    Dim args As DateTimeScaleChangedEventArgs = TryCast(e, DateTimeScaleChangedEventArgs)
    If (args Is Nothing) OrElse (args Is Nothing) Then
        Return
    End If
    axis.Title.Text = String.Format("The Axis Grid Alignment Unit is {0}" & vbCrLf & "The Axis Measure Unit is {1}", args.GridAlignmentChange.NewValue, args.MeasureUnitChange.NewValue)
End Sub

See Also

Data Aggregation

ChartControl Class

ChartControl Members

DevExpress.XtraCharts Namespace