Xceed Chart for WinForms v4.4 Documentation
Welcome to Xceed Chart for WinForms v4.4 / User Guide / Axes / Axis Attributes / Labels

In This Topic
    Labels
    In This Topic

    Axis labels are labels displayed at custom axis values. In conjunction with axes, constant lines, and stripes, they form the primary means with which the user can direct attention to a specific axis value or value range and display some explanatory text. 

    The image on figure one displays a typical example of the usage of axis labels for explanatory texts of constant lines and stripes. 



    figure 1.

    Creating a New Axis Label

    Each axis label is represented by an AxisLabel object. Axis labels are contained in an AxisLabelCollection object, which can be accessed using the Labels property of the Axis object. The Value property specifies the value on which the axis label will be displayed, while the actual text that will be displayed is controlled by the Text property. 

    The following example creates an axis label at value 10 of the PrimaryY chart axis:

    VB.NET  

    Dim label As AxisLabel

    label = Chart.Axis(StandardAxis.PrimaryY).Labels.Add()

    label.Value = 10

    label.Text = "Very important limit"

    C#  
    AxisLabel label;
    label = Chart.Axis(StandardAxis.PrimaryY).Labels.Add();
    label.Value = 10;
    label.Text = "Very important limit";

    Controlling the Appearance of the Axis Label Text

    The user can control the display properties of text with the ChartText object accessible via the TextProps property. The following example changes the font and size of the label:

    VB.NET  

    label.TextEx.Font.Name = "Arial"

    label.TextEx.Font.Size = 12

    C#  
    label.TextProps.Font.Name = "Arial";
    label.TextProps.Font.Size = 12;

    Controlling the Axis Label Position

    An axis label can be detached from its position on the axis. This increases its readability in most cases. The Offset property of the AxisLabel object specifies this detachment in Model units. The user can also control the direction of this offset with the Angle property. For example, labels on the PrimaryY axis are usually detached with an angle of 180 degrees, which offsets the labels to the left of the chart, while labels displayed on the PrimaryX axis are usually offset with an angle of 270 degrees, which offsets the labels to the bottom of the chart.

    VB.NET  

    ' 0.3 Model units from the left axis

    label.Offset = 0.3

     

    ' offsets on the left of the axis

    label.Angle = 180

    C#  
    // 0.3 Model units from the left axis
    label.Offset = 0.3;
    // offsets on the left of the axis
    label.Angle = 180;

    Controlling the Label Connection Line

    The user can also display a connection line between the original position of the axis label on the chart axis and the position of the label after the offset has been performed. The user can change its appearance with the LineProperties object accessible through LineProps property.

    VB.NET  

    label.HasLine = True

    label.LineProps.Color = Color.Blue

    C#  
    label.HasLine = true;
    label.LineProps.Color = Color.Blue;

    Related Examples

    Windows Forms: Axes\Attributes\Custom Labels

    See Also

    Axis | AxisLabelCollection | AxisLabel