Skip to main content
A newer version of this page is available. .

CustomAxisLabelCollection.Add(CustomAxisLabel) Method

Appends the specified CustomAxisLabel object to the current collection.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v18.2.dll

Declaration

public int Add(
    CustomAxisLabel label
)

Parameters

Name Type Description
label CustomAxisLabel

A CustomAxisLabel object to append to the collection.

Returns

Type Description
Int32

An integer value indicating the position at which the new element was inserted.

Remarks

This method adds a CustomAxisLabel object to the end of the collection.

Example

This example demonstrates how custom axis labels can be created and customized at runtime.

using System;
using System.Drawing;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace CustomAxisLabels {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }

        #region #CustomLabels
        private void Form1_Load(object sender, EventArgs e) {
            // Cast the chart's diagram to the XYDiagram type, to access its axes.
            XYDiagram diagram = chartControl.Diagram as XYDiagram;
            if(diagram == null) return;

            AxisX axisX = diagram.AxisX;
            // Add a custom label to the X-axis.
            axisX.CustomLabels.Add(new CustomAxisLabel(name: "State of Michigan", value: "Michigan") {
                TextColor = Color.FromArgb(255, 74, 74, 74),
                BackColor = Color.FromArgb(255, 225, 225, 225)
            });
            // Make auto-generated and custom labels visible at the same time.
            axisX.LabelVisibilityMode = AxisLabelVisibilityMode.AutoGeneratedAndCustom;
        }
        #endregion
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Add(CustomAxisLabel) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also