AxisLabelItem Class

Represents an individual axis label item.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v20.1.dll

Declaration

public class AxisLabelItem :
    AxisLabelItemBase,
    IAxisLabelLayout
Public Class AxisLabelItem
    Inherits AxisLabelItemBase
    Implements IAxisLabelLayout

Remarks

The AxisLabelItem class contains settings that define the functionality of an individual axis label item, obtained in the special ChartControl.CustomDrawAxisLabel (or WebChartControl.CustomDrawAxisLabel) event handler.

In this event, you can use the CustomDrawAxisLabelEventArgs.Item property to obtain an axis label item's axis value (or internal value, if it's needed), its font and appearance settings, and also access the properties of the associated axis itself.

AxisLabelItem

For more information, refer to Axis Labels.

Examples

Apart from the capability to customize the overall appearance of axis labels, you can obtain individual axis labels at runtime. Then, it's possible to apply all the options available for axis labels to them, individually. For example, based on some criteria (e.g. an axis value threshold), you can apply different formatting to axis labels.

For this, the special ChartControl.CustomDrawAxisLabel event is introduced. Handle it to obtain axis labels.

NOTE

For the WebChartControl you should handle its WebChartControl.CustomDrawSeries event to implement this task.

The following code demonstrates one possible implementation of this capability.

private void chartControl1_CustomDrawAxisLabel(object sender, CustomDrawAxisLabelEventArgs e) {
    AxisBase axis = e.Item.Axis;
    if (axis is AxisY || axis is AxisY3D || axis is RadarAxisY) {
        double axisValue = (double)e.Item.AxisValue;
        if (axisValue < 0) {
            e.Item.TextColor = Color.Red;
        }
        else if (axisValue > 0) {
            e.Item.Text = "+" + e.Item.Text;
            e.Item.TextColor = Color.Green;
        }
        else if (axisValue == 0) {
            e.Item.Text = "Zero";
        }
    }
}

Inheritance

See Also