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 | |
---|---|
|
C# | |
---|---|
AxisLabel label; |
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 | |
---|---|
|
C# | |
---|---|
label.TextProps.Font.Name = "Arial"; |
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 | |
---|---|
|
C# | |
---|---|
// 0.3 Model units from the left axis // offsets on the left of the axis |
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 | |
---|---|
|
C# | |
---|---|
label.HasLine = true; |
Related Examples
Windows Forms: Axes\Attributes\Custom Labels