Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Expand]WinForms Controls
[Collapse]ASP.NET Controls and MVC Extensions
 [Expand]Prerequisites
 [Expand]What's Installed
 [Expand]Common Concepts
 [Collapse]ASP.NET WebForms Controls
  [Expand]Reporting
  [Collapse]Chart Control
   [Expand]Product Information
   [Expand]Getting Started
   [Expand]Fundamentals
   [Collapse]Concepts
    [Expand]Creating Charts
    [Collapse]Chart Elements
     [Expand]Series
     [Expand]Diagram
     [Collapse]Axes
       Axes Overview
       Axis Scale Types
       Visual Ranges and Whole Ranges
       Primary and Secondary Axes
       Grid Lines,Tickmarks and Interlacing
       Axis Appearance and Position
       Axis Titles
       Axis Labels
       Strips
       Constant Lines
       Scale Breaks
     [Expand]Panes
     [Expand]Legend
     [Expand]Chart Titles
     [Expand]Annotations
     [Expand]Indicators
    [Expand]End-User Interaction
     Supported Browsers
     Adding a Web Chart
     Handling Client-side Scripts
     Medium Trust Support
     Web Farm and Web Gardens Support
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]Examples
  [Expand]Grid View
  [Expand]Card View
  [Expand]Vertical Grid
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Image and Data Browsing
  [Expand]Docking and Popups
  [Expand]Site Navigation and Layout
  [Expand]File Management
  [Expand]Multi-Use Site Controls
  [Expand]Scheduler
  [Expand]HTML Editor
  [Expand]Pivot Grid
  [Expand]Tree List
  [Expand]Gauges
  [Expand]Data Editors
  [Expand]Spell Checker
  [Expand]Query Builder
 [Expand]ASP.NET MVC Extensions
 [Expand]Localization
 [Expand]Redistribution and Deployment
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Bootstrap Controls
[Expand]ASP.NET Core Bootstrap Controls
[Expand]WPF Controls
[Expand]Xamarin Controls
[Expand]Windows 10 App Controls
[Expand]Document Server
[Expand]Reporting
[Expand]Report Server
[Expand]Dashboard
[Expand]eXpressApp Framework
[Expand]CodeRush
[Expand]CodeRush Classic
[Expand]Cross-Platform Core Libraries
[Expand]Tools and Utilities
 End-User Documentation

Axis Labels

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.

Expanded Default Axis Labels

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.

Note

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.

The appearance of axis labels can be customized via the Axis2D.Label property. The AxisLabel.TextPattern property allow you to format an axis labels' text.

Note

The appearance properties affect both default and custom axis labels, with the exception of the AxisLabel.TextPattern property, which have no effect upon custom labels.

Expanded Custom Axis Labels

Besides the default axis labels, it is possible to add custom ones.

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:

  1. Locate the Axis2D.CustomLabels property in the Properties window and click its ellipsis button.

  2. This invokes the Custom Axis Label Collection Editor.

  3. In this dialog, click Add to create a custom label, and customize its CustomAxisLabel.AxisValue and ChartElementNamed.Name properties.

    Note that the value set for the CustomAxisLabel.AxisValue property should lie in the range specified by the AxisBase.WholeRange property, in order for the custom label to be visible on a diagram.

    Finally, click Close, to apply the changes and quit the dialog.

Since most of the appearance settings of axis' custom labels are defined via the Axis2D.Label property of the axis, custom axis labels share their appearance settings with an axis' default labels.

Note

Custom labels defined for an axis cannot be displayed along with its default labels. If an axis's Axis2D.CustomLabels collection does not contain a custom label whose CustomAxisLabel.Visible property is set to true, the default labels are displayed within the axis, instead.

Expanded Axis Label Item

There is the capability to obtain an individual axis label at runtime for both default and custom axis labels in the specific WebChartControl.CustomDrawAxisLabel event.

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.

A code example detailing how to achieve this can be found at How to: Individually Customize Axis Labels.

Expanded Format Axis Labels

To apply a date-time format to axis labels, use the AxisLabel.TextPattern property. At design time, you can locate it in the Properties window after selecting the required axis.

This property defines a pattern for displaying text by series labels. Various placeholders enclosed in braces correspond to the available display patterns.

The full list of available placeholders is listed below.

Pattern Description
{A} Displays a series point argument.
{V} Displays series point values.
{VP} Displays series point values as percentages (for a Pie series and Full-Stacked series views).
{S} Displays the name of the series.
{G} Displays the name of a stacked group.
{W} Displays the weight (for a Bubble series).
{V1} Displays the first value (for a Range series).
{V2} Displays the second value (for a Range series).
{HV} Displays the high value (for a Financial series).
{LV} Displays the low value (for a Financial series).
{OV} Displays the open value (for a Financial series).
{CV} Displays the close value (for a Financial series).
{HINT} Displays a hint for a series point.

You can use standard and custom format specifiers, together with the placeholders to format numeric and date/time values (e.g., "{A}: {V:F1}") .

The result is shown below.

To learn more, see the Format Specifiers topic.

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.

To invoke the editor, click the ellipsis button of the SeriesLabelBase.TextPattern property in the Properties window.

You can also customize the text pattern in the "Text Pattern" tab, which is located in the "Point Labels" Chart Wizard section.

Expanded Resolve Overlapping for Axis Labels

There are situations when axis labels do not have enough space to represent all the information, for example, of a series argument.

The resolve overlapping algorithm allows you to accomplish this task for axis labels.

Note that you do not need to write any lines of code to provide this feature, because all the necessary options (axis labels rotating, staggering and hiding) are available, by default.

You can customize the way the resolve overlapping is provided for axis labels by using the properties of the AxisLabelResolveOverlappingOptions object. This object can be accessed via the AxisLabel.ResolveOverlappingOptions property.

The following table lists properties that can be used to customize the resolve overlapping algorithm:

Member Description
AxisLabelResolveOverlappingOptions.AllowHide Gets or sets a value indicating whether or not to hide axis labels when resolving any overlap.
AxisLabelResolveOverlappingOptions.AllowRotate Gets or sets a value indicating whether or not to rotate axis labels when resolving overlapping labels.
AxisLabelResolveOverlappingOptions.AllowStagger Gets or sets a value indicating whether or not to stagger axis labels when resolving overlapping labels.
AxisLabelResolveOverlappingOptions.MinIndent Gets or sets the minimum indent between adjacent axis labels, when an overlap resolution algorithm is applied to them.

Expanded See Also

How would you rate this topic?​​​​​​​