This document describes how default and custom axis labels can be displayed and customized. Before you proceed with this document, you may wish to review the basics of using axes.
There are two types of axis labels available in the ASP.NET Chart Control: default and custom. And, it is possible to obtain an individual axis label item at runtime. In addition, axis labels support an algorithm which prevents label overlap during resizing.
So, this document consists of the following sections.
The default axis labels represent textual values for major tickmarks of a diagram's axes.
Axis labels are generated automatically based on the scale type of the axis to which they belong.
To organize the default axis labels in a custom order when the qualitative scale type is specified, create a static series with points corresponding to the required axis values. Then, arrange points within the series in the required order, and set this series as the first item in the chart's collection of series.
An individual custom label is represented by an instance of the CustomAxisLabel class. Custom labels of an axis reside in the axis' CustomAxisLabelCollection, which can be accessed via the Axis2D.CustomLabels property. If the collection is empty (or does not contain any visible custom labels), the chart control shows default axis labels.
To add custom labels to an axis at design time, do the following:
Locate the Axis2D.CustomLabels property in the Properties window and click its ellipsis button.
This invokes the Custom Axis Label Collection Editor.
For example, it may be required to customize the appearance of axis labels, based on their values. So, to achieve this, handle the event listed above, and write the required condition in its handler. The result is shown in the following image.
In addition, you can specify a pattern using the Pattern Editor. The editor contains numerous predefined chart placeholders together with the date-time, numeric, percent, currency, and special formats allowing you to create a text pattern.