Axis Labels

An axis label displays text along a graph's axis that can be specified or set automatically. Both the XAxisLabel and YAxisLabelare subclasses of AxisLabel. You use the Labels property (a list) to add labels to an axis. You then assign labels to the labels list. The following code illustrates adding labels to an IndexedXAxis.

IndexedXAxis xAxis = new IndexedXAxis();
// Create indexed axis labels and add those to indexed xAxis
xAxis.Labels.Add(new IndexedXAxisLabel("Q1", 0));
xAxis.Labels.Add(new IndexedXAxisLabel("Q2", 1));
xAxis.Labels.Add(new IndexedXAxisLabel("Q3", 2));
xAxis.Labels.Add(new IndexedXAxisLabel("Q4", 3));

To add axis labels automatically, set its AutoLayout property to True.

The following table lists the label type, label list type, and axis type.

Label Label List Type
AxisLabel AxisLabelList Axis
X-Axis Label X-Axis Label List X-Axis Type
XAxisLabel XAxisLabelList
DateTimeXAxisLabel DateTimeXAxisLabelList DateTimeXAxis
IndexedXAxisLabel IndexedXAxisLabelList IndexedXAxis
NumericXAxisLabel NumericXAxisLabelList NumericXAxis
PercentageXAxisLabel PercentageXAxisLabelList PercentageXAxis
Y-AxisLabel Y-Axis Label List Y-Axis Type
YAxisLabel YAxisLabelList YAxis
DateTimeYAxisLabel DateTimeYAxisLabelList DateTimeYAxis
IndexedYAxisLabel IndexedYAxisLabelList IndexedYAxis
NumericYAxisLabel NumericYAxisLabelList NumericYAxis
PercentageYAxisLabel PercentageYAxisLabelList PercentageYAxis

AxisLabel

The AxisLabel class is the parent to both XAxisLabel and YAxisLabel and has the following properties shared by both subclasses.

Properties

Property Description
Font Gets or sets the Font object to use for the text of the axis label.
FontSize Gets or sets the font size for the text of the axis label.
Text Gets or sets the text of the axis label.
TextColor Gets or sets the Color object to use for the text of the axis label.

XAxisLabel

The XAxisLabel displays labels along an x-axis. This class is parent to the DateTimeXAxisLabel, IndexedXAxisLabel, NumericXAxisLabel, and PercentageXAxisLabel.

Label Rotation

Rotate the XAxisLabel angle using the XAxisLabelPosition enumeration using the XAxis.LabelPosition property. The XAxisLabelPosition enumeration default value is BelowXAxis, other position values include AbovePlotArea, AboveXAxis, Automatic, and BelowPlotArea.

DateTimeXAxisLabel

The DateTimeXAxis displays date/time values using the DateTimeXAxisLabel. Use this class to display date/time data along a DateTimeXAxis.

Properties

This class inherits the properties of XAxisLabel and AxisLabel and adds an additional Value property.

Property Description
Value Sets a DateTime value.

The following code illustrates adding a DateTimeXAxisLabel to a DateTimeXAxis.

DateTimeXAxis xAxis = new DateTimeXAxis();
xAxis.Labels.Add(new DateTimeXAxisLabel("Tues",new DateTime(2008,1,1)));
xAxis.Labels.Add(new DateTimeXAxisLabel("Wednes", new DateTime(2008,1,2)));
xAxis.Labels.Add(new DateTimeXAxisLabel("Thurs", new DateTime(2008,1,3)));
xAxis.Labels.Add(new DateTimeXAxisLabel("Fri", new DateTime(2008,1,4)));        
Dim MyXAxis As DateTimeXAxis = New DateTimeXAxis()
MyXAxis.Labels.Add(New DateTimeXAxisLabel("Tues", New Date(2008, 1, 1)))
MyXAxis.Labels.Add(New DateTimeXAxisLabel("Wednes", New Date(2008, 1, 2)))
MyXAxis.Labels.Add(New DateTimeXAxisLabel("Thurs", New Date(2008, 1, 3)))
MyXAxis.Labels.Add(New DateTimeXAxisLabel("Fri", New Date(2008, 1, 4)))       

Refer to the DateTimeXAxisLabel API documentation for a complete example.

IndexedXAxisLabel

The IndexedXAxis use IndexedXAxisLabel to display integer values along the XAxis.

Properties

This class inherits the properties of XAxisLabel and AxisLabel and adds an additional Value property.

Property Description
Value Sets an Int32 value.

The below code shows how to add an IndexedXAxisLabel to an IndexedXAxis.

IndexedXAxis xAxis = new IndexedXAxis();
xAxis.Labels.Add(new IndexedXAxisLabel("Q1", 0));
xAxis.Labels.Add(new IndexedXAxisLabel("Q2", 1));
xAxis.Labels.Add(new IndexedXAxisLabel("Q3", 2));
xAxis.Labels.Add(new IndexedXAxisLabel("Q4", 3));        
Dim MyXAxis As IndexedXAxis = New IndexedXAxis()
MyXAxis.Labels.Add(New IndexedXAxisLabel("Q1", 0))
MyXAxis.Labels.Add(New IndexedXAxisLabel("Q2", 1))
MyXAxis.Labels.Add(New IndexedXAxisLabel("Q3", 2))
MyXAxis.Labels.Add(New IndexedXAxisLabel("Q4", 3))       

See the IndexedXAxisLabel API documentation for a complete example.

NumericXAxisLabel

The NumericXAxis uses NumericXAxisLabel instances to display numeric values along the XAxis.

Properties

This class inherits the properties of XAxisLabel and AxisLabel and add an additional Value property.

Property Description
Value Sets an Single value.

The below code shows how to add a NumericXAxisLabel to a NumericXAxis.

NumericXAxis xAxis = new NumericXAxis();
xAxis.Labels.Add(new NumericXAxisLabel("1", 10));
xAxis.Labels.Add(new NumericXAxisLabel("2", 20));
xAxis.Labels.Add(new NumericXAxisLabel("3", 30));
xAxis.Labels.Add(new NumericXAxisLabel("4", 40));        
Dim MyXAxis As NumericXAxis = New NumericXAxis()
MyXAxis.Labels.Add(New NumericXAxisLabel("1", 10))
MyXAxis.Labels.Add(New NumericXAxisLabel("2", 20))
MyXAxis.Labels.Add(New NumericXAxisLabel("3", 30))
MyXAxis.Labels.Add(New NumericXAxisLabel("4", 40))

Note: See the NumericXAxisLabel API documentation for a complete example.

PercentageXAxisLabel

The PercentageXAxis uses PercentageXAxisLabel instances to display percentage values along the XAxis.

Properties

This class inherits the properties of XAxisLabel and AxisLabel and add an additional Value property.

Property Description
Value Sets a float value.

The below code shows how to add a PercentageXAxisLabel to a PercentageXAxis.

PercentageXAxis xAxis = new PercentageXAxis();
xAxis.Labels.Add(new PercentageXAxisLabel("10%",10));
xAxis.Labels.Add(new PercentageXAxisLabel("20%",20));
xAxis.Labels.Add(new PercentageXAxisLabel("30%",30));
xAxis.Labels.Add(new PercentageXAxisLabel("40%",40));        
Dim MyXAxis As PercentageXAxis = New PercentageXAxis()
MyXAxis.Labels.Add(New PercentageXAxisLabel("10%", 10))
MyXAxis.Labels.Add(New PercentageXAxisLabel("20%", 20))
MyXAxis.Labels.Add(New PercentageXAxisLabel("30%", 30))
MyXAxis.Labels.Add(New PercentageXAxisLabel("40%", 40)) 

See the PercentageXAxisLabel API documentation for a complete example.

YAxisLabel

The YAxisLabel displays labels along a y-axis. This class is parent to the DateTimeYAxisLabel, IndexedYAxisLabel, NumericYAxisLabel, and PercentageYAxisLabel.

Label Rotation

Rotate the YAxisLabel angle using the YAxisLabelPosition enumeration using the YAxis.LabelPosition property. The YAxisLabelPosition enumeration default value is LeftOfYAxis. , other position values include Automatic, LeftOfPlotArea, RightOfPlotArea, and RightOfYAxis.

DateTimeYAxisLabel

The DateTimeYAxis uses DateTimeYAxisLabel instances to display values along the YAxis. It displays the values as date/time values.

Properties

This class inherits the properties of YAxisLabel and AxisLabel and add an additional Value property.

Property Description
Value Sets a DateTime value.

The below code shows how to add a DateTimeYAxisLabel to a DateTimeYAxis.

DateTimeYAxis yAxis = new DateTimeYAxis();
yAxis.Labels.Add(new DateTimeYAxisLabel("Tues",new DateTime(2008,1,1)));
yAxis.Labels.Add(new DateTimeYAxisLabel("Wednes", new DateTime(2008,1,2)));
yAxis.Labels.Add(new DateTimeYAxisLabel("Thurs", new DateTime(2008,1,3)));
yAxis.Labels.Add(new DateTimeYAxisLabel("Fri", new DateTime(2008,1,4)));        
Dim MyYAxis As DateTimeYAxis = New DateTimeYAxis()
MyYAxis.Labels.Add(New DateTimeYAxisLabel("Tues", New Date(2008, 1, 1)))
MyYAxis.Labels.Add(New DateTimeYAxisLabel("Wednes", New Date(2008, 1, 2)))
MyYAxis.Labels.Add(New DateTimeYAxisLabel("Thurs", New Date(2008, 1, 3)))
MyYAxis.Labels.Add(New DateTimeYAxisLabel("Fri", New Date(2008, 1, 4)))      

Refer to the DateTimeYAxis API documentation for a complete example.

IndexedYAxisLabel

The IndexedYAxis uses IndexedYAxisLabel instances to display integer values along the YAxis.

Properties

This class inherits the properties of YAxisLabel and AxisLabel and add an additional Value property.

Property Description
Value Sets an Int32 value.

The below code shows how to add an IndexedYAxisLabel to an IndexedYAxis,

IndexedYAxis yAxis = new IndexedYAxis();
yAxis.Labels.Add(new IndexedYAxisLabel("Q1", 0));
yAxis.Labels.Add(new IndexedYAxisLabel("Q2", 1));
yAxis.Labels.Add(new IndexedYAxisLabel("Q3", 2));
yAxis.Labels.Add(new IndexedYAxisLabel("Q4", 3));        
Dim MyYAxis As IndexedYAxis = New IndexedYAxis()
MyYAxis.Labels.Add(New IndexedYAxisLabel("Q1", 0))
MyYAxis.Labels.Add(New IndexedYAxisLabel("Q2", 1))
MyYAxis.Labels.Add(New IndexedYAxisLabel("Q3", 2))
MyYAxis.Labels.Add(New IndexedYAxisLabel("Q4", 3))      

Refer to the IndexedYAxis API documentation for a complete example.

NumericYAxisLabel

The NumericYAxis uses NumericYAxisLabel instances to display values along the YAxis.

Properties

This class inherits the properties of YAxisLabel and AxisLabel and adds an additional Value property.

Property Description
Value Sets an Single value.

The below code shows how to add a NumericYAxisLabel to a NumericYAxis.

NumericYAxis yAxis = new NumericYAxis();
yAxis.Labels.Add(new NumericYAxisLabel("1", 10));
yAxis.Labels.Add(new NumericYAxisLabel("2", 20));
yAxis.Labels.Add(new NumericYAxisLabel("3", 30));
yAxis.Labels.Add(new NumericYAxisLabel("4", 40));        
Dim MyYAxis As NumericYAxis = New NumericYAxis()
MyYAxis.Labels.Add(New NumericYAxisLabel("1", 10))
MyYAxis.Labels.Add(New NumericYAxisLabel("2", 20))
MyYAxis.Labels.Add(New NumericYAxisLabel("3", 30))
MyYAxis.Labels.Add(New NumericYAxisLabel("4", 40))             

Refer to the NumericYAxis API documentation for a complete example.

PercentageYAxisLabel

The PercentageYAxis uses PercentageYAxisLabel instances to display values along the YAxis. It displays the text in percentage format.

Properties

This class inherits the properties of YAxisLabel and AxisLabel and adds an additional Value property.

Property Description
Value Sets a float alue.

The below code shows how to add a PercentageYAxisLabel to a PercentageYAxis.

PercentageYAxis yAxis = new PercentageYAxis();
yAxis.Labels.Add(new PercentageYAxisLabel("10%",10));
yAxis.Labels.Add(new PercentageYAxisLabel("20%",20));
yAxis.Labels.Add(new PercentageYAxisLabel("30%",30));
yAxis.Labels.Add(new PercentageYAxisLabel("40%",40));        
Dim MyYAxis As PercentageYAxis = New PercentageYAxis()
MyYAxis.Labels.Add(New PercentageYAxisLabel("10%", 10))
MyYAxis.Labels.Add(New PercentageYAxisLabel("20%", 20))
MyYAxis.Labels.Add(New PercentageYAxisLabel("30%", 30))
MyYAxis.Labels.Add(New PercentageYAxisLabel("40%", 40))      

Refer to PercentageYAxis API documentation for a complete example.

In this topic