Each axis provides several smaller objects that control its appearance and/or are controlled by the axis. The matter concerns tick marks, axis labels, and grids. They are described in the current topic.
Tick Marks
A tick mark on an axis is represented by the TickMark class. It provides several properties which sets up its appearance.
Setting a Color
You can control the color of the tick mark using the Color property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=2
Setting a Width
You can get or set the width of the tick mark in pixels using the Width property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=2
Setting a Length
You can get or set the length of the tick mark in pixels using the Length property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=2
Setting a Style
You can control the style of the tick mark using the Style property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=2
Controlling the Visibility
You can make the tick mark visible or not using the IsVisible property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=2
Axis Labels
A single axis label is represented by the AxisLabel class. It provides properties that allow you to customize the look of various labels on an axis of a chart.
Setting a Text
Control the text of the label via the Text property. You can get or set the format of the text using the Format property; the format string complies with Formatting Types in the .NET Framework.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=6
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=3
Setting a Color
You can get or set the color of the label text using the Color property. The default value is Color.Black.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=6
Setting a Font
The font of the label text is controlled by the Font property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=6
Setting a Text Angle
The angle of the label text can be managed using the FontAngle property. Its value can be from -90 to 90 degrees.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=8
Controlling the Visibility
You can switch the label visibility on or off using the IsVisible property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=6
"Connecting" to the Axis Values
If the axis label is automatically generated, you can obtain the value on the axis along which the label is drawn. This is returned by the Value property.
If the axis label is custom (user defined), use the FromValue and ToValue properties which specify where the label is "connected" to the axis. When the FromValue and ToValue properties are set, a custom label is drawn with a bracket showing that the label applies to a range of values on the axis.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=8
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=6
Grids
Grids are represented by the Grid class. The Grid class contains a couple of properties which manage the grid appearance.
Setting a Color
Use the Color property to control the color of the grid lines.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=40
Setting a Width
The width of the grid lines is controlled by the Width property. The default value is 1 pixel.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=2
Setting a Style
You can manage the style of the grid lines using the Style property.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=2
Controlling the Visibility
You can make the horizontal or vertical lines of the grid visible or not by setting the IsHorizontalLinesVisible or IsVerticalLinesVisible properties, respectively.
Example
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=40
http://www.aspose.com/Products/Aspose.Chart/Demos/CodeChart.aspx?GalleryItemId=11
Code Sample
[C#]
// --- Configuring major tick mark ---
TickMark tickMark = axis.MajorTickMark;
// Setting color
tickMark.Color = Color.Azure;
// Setting width
tickMark.Width = 1;
// Setting length
tickMark.Length = 5;
// Setting style
tickMark.Style = DashStyle.Dash;
// --- Configuring one axis label ---
AxisLabel label = axis.AxisLabels[0];
// Setting text
label.Text = "I'm a fine label";
// Setting color
label.Color = Color.DarkOliveGreen;
// Setting font
label.Font = new Font("Arial", 10);
// --- Configuring major grid ---
Grid grid = axis.MajorGrid;
// Setting color
grid.Color = Color.YellowGreen;
// Setting width
grid.Width = 1;
// Setting style
grid.Style = DashStyle.DashDot;
[VB .NET]
' --- Configuring major tick mark ---
Dim tickMark As TickMark = axis.MajorTickMark
' Setting color
tickMark.Color = Color.Azure
' Setting width
tickMark.Width = 1
' Setting length
tickMark.Length = 5
' Setting style
tickMark.Style = DashStyle.Dash
' --- Configuring one axis label ---
Dim label As AxisLabel = axis.AxisLabels(0)
' Setting text
label.Text = "I'm a fine label"
' Setting color
label.Color = Color.DarkOliveGreen
' Setting font
label.Font = New Font("Arial", 10)
' --- Configuring major grid ---
Dim grid As Grid = axis.MajorGrid
' Setting color
grid.Color = Color.YellowGreen
' Setting width
grid.Width = 1
' Setting style
grid.Style = DashStyle.DashDot