Log In
Home
Support
Demos
Documentation
Blogs
Training
Webinars
[Expand]General Information
[Collapse]WinForms Controls
  Prerequisites
 [Expand]What's Installed
 [Expand]Build an Application
 [Collapse]Controls and Libraries
  [Expand]Forms and User Controls
  [Expand]Messages, Notifications and Dialogs
  [Expand]Editors and Simple Controls
  [Expand]Ribbon, Bars and Menu
  [Expand]Application UI Manager
  [Expand]Docking Library
  [Expand]Data Grid
  [Expand]Vertical Grid
  [Expand]Pivot Grid
  [Expand]Tree List
  [Collapse]Chart Control
   [Expand]Getting Started
   [Collapse]Fundamentals
    [Expand]Charting Basics
    [Expand]Professional Charting
    [Expand]Series Views
    [Collapse]Chart Elements
     [Expand]Series
     [Collapse]Diagram
      [Expand]Diagram Types
      [Collapse]Axes
        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
      Chart Titles
     [Expand]Legends
     [Expand]Annotations
   [Expand]Providing Data
   [Expand]Appearance Customization
   [Expand]End-User Features
   [Expand]Design-Time Features
   [Expand]Visual Elements
   [Expand]Examples
   [Expand]Additional Resources
  [Expand]Diagrams
  [Expand]Gauges
  [Expand]Map Control
  [Expand]Scheduler
  [Expand]Spreadsheet
  [Expand]Rich Text Editor
  [Expand]Spell Checker
  [Expand]Form Layout Managers
  [Expand]Navigation Controls
  [Expand]Printing-Exporting
  [Expand]PDF Viewer
   Reporting
  [Expand]Snap
  [Expand]TreeMap Control
 [Expand]Common Features
  Get More Help
 [Expand]API Reference
[Expand]ASP.NET Controls and MVC Extensions
[Expand]ASP.NET 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]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 XtraCharts: default and custom. It's possible to obtain an individual axis label item at runtime. In addition, axis labels support an algorithm that prevents label overlap during resizing.

Thus, this document consists of the following sections.

Expanded Default Axis Labels

The default axis labels represent textual values for major tickmarks of a diagram axes.

Axis labels are generated automatically based on the scale type of the axis to which they belong.

Note that when the qualitative scale type is specified, and you are required to organize the default axis labels in a custom order, create an instance of a class implementing the System.Collections.IComparer interface and assign it to the AxisBase.QualitativeScaleComparer property of an axis. This object will sort axis values in the required order.

The appearance of axis labels can be customized using the Axis2D.Label property. The AxisLabel.TextPattern property allows you to format axis label text.

Note

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

Expanded Custom Axis Labels

In addition to the default axis labels, it's 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 using the Axis2D.CustomLabels property. If the collection is empty (or doesn't contain any visible custom labels), the default axis labels are shown.

To add custom labels to an axis at design time, do the following.

  1. Select the required axis in the chart's diagram, and in the Properties window, locate the Axis2D.CustomLabels property.
  2. Click its ellipsis button to invoke 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 using the Axis2D.Label property of the axis, custom axis labels share their appearance settings with an axis' default labels.

Note

By default, custom labels defined for an axis can't be displayed along with its default labels. If an axis's Axis2D.CustomLabels collection doesn't contain a custom label whose CustomAxisLabel.Visible property is set to true, the default labels are displayed within the axis instead. To show both default and custom labels, set the Axis2D.LabelVisibilityMode property to AutoGeneratedAndCustom.

Expanded Axis Label Item

To customize text or appearance of an individual axis label, handle the ChartControl.CustomDrawAxisLabel event, which passes an AxisLabelItemBase object as a parameter. Use this object to modify axis labels as required.

Note

Note that the CustomDrawAxisLabel event enables you to modify default and custom axis labels.

For instance, you can change axis label color based on their values, as shown in the image below.

See the detailed example 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.

Since series labels represent data of their corresponding series points, you can apply formatting to this data using the SeriesLabelBase.TextPattern property. This property defines a pattern for displaying text by series labels. Various placeholders enclosed in braces correspond to the available display patterns.

A full list of available placeholders is detailed below.

Pattern Description
{A} Displays a series point argument.
{V} Displays series point values.
{VP} Displays series point values as percentages (for a Pie (Donut) series and Full-Stacked series).
{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 range series).
{V2} Displays the second value (for range series).
{VD} Displays the duration between the first and second data point values (for 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).
Note

If the {VD} placeholder is used and the duration value is a date-time value, one of the following custom format specifiers can be used.

  • TD - displays total days.
  • TH - displays total hours.
  • TM - displays total minutes.
  • TS - displays total seconds.
  • TMS - displays total milliseconds.

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 don't 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 don' t need to write any lines of code to provide this feature, because all the necessary options (axis labels rotating, staggering and hiding during chart resizing) are available by default.

You can customize the way resolve overlapping is provided for axis labels by using the properties of the AxisLabelResolveOverlappingOptions object. This object can be accessed using 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?​​​​​​​