Nevron .NET Vision

In This Topic
    Labels
    In This Topic

    Axis custom labels are labels displayed at custom axis values. Along with axis constant lines and stripes they form the primary means by which you can direct the attention to a specific axis value or value range.

    The following image displays an example of the usage of axis custom labels for explanatory texts of const lines and stripes.



    figure 1.

     Creating a new axis label

    Each axis label is represented by a NAxisCustomLabel object. The axis labels are contained in a NAxisCustomLabelCollection object, which can be accessed through the CustomLabels property of the NAxis object. The Value property specifies the value at which the axis label will be displayed. The actual text is controlled through the Text property.

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

    C#
    Copy Code
    NAxisLabel label = chart.Axis(StandardAxis.PrimaryY).Labels.Add();
    label.Value = 10;
    label.Text = "Very important limit";
    
    Visual Basic
    Copy Code
    Dim label As NAxisCustomLabel = chart.Axis(StandardAxis.PrimaryY).CustomLabels.Add()
    label.Value = 10
    label.Text = "Very important limit"
    
     Controlling the appearance of the label text

    You can control the label text style with the help of a NTextStyle object accessible through the TextStyle method. The following example will change the font of the label:

    C#
    Copy Code
    label.TextStyle.FontStyle = new NFontStyle("Arial", 12);
    
    Visual Basic
    Copy Code
    label.TextStyle.FontStyle = New NFontStyle("Arial", 12)
    
     Controlling the label position

    The axis label can be detached from its position on the axis. In most cases this will increase its readability. The Offset property of the NAxisCustomLabel object specifies this detachment in Model units. You can also control the direction of this offset with help of the Angle property. For example labels on the PrimaryY axis are usually detached with angle 180 (offsets the labels to the left of the chart), while labels displayed on the PrimaryX axis are usually offset with angle 270 (offsets the labels to the bottom of the chart).

    C#
    Copy Code
    label.Offset = 6.0;
    label.Angle = 180;
    
    Visual Basic
    Copy Code
    label.Offset = 6.0F
    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 an offset has been performed. You can change the line appearance with the help of a NStrokeStyle object accessible through the StrokeStyle property.

    C#
    Copy Code
    label.StrokeStyle.Color = Color.Blue;
    
    Visual Basic
    Copy Code
    label.StrokeStyle.Color = Color.Blue
    
     Related Examples
    Windows forms: Axes\Attributes\Custom Labels
    See Also