Skip to main content

AxisTitle.Alignment Property

Gets or sets the alignment of the axis title.

Namespace: DevExpress.XtraCharts

Assembly: DevExpress.XtraCharts.v24.1.dll

NuGet Package: DevExpress.Charts

Declaration

[TypeConverter(typeof(StringAlignmentTypeConvertor))]
[XtraChartsLocalizableCategory(XtraChartsCategory.Behavior)]
[XtraSerializableProperty]
public StringAlignment Alignment { get; set; }

Property Value

Type Description
StringAlignment

A StringAlignment enumeration value which specifies the alignment of the axis title.

Remarks

The following images demonstrate the Alignment property in action.

Near Center Far
AxisTitle_Near AxisTitle_Center AxisTitle_Far

For more information, refer to Axis Titles.

Example

This example demonstrates how to access an axis title at runtime.

Customize an axis title

Cast your diagram object to the required diagram type to access its axes. Then, you can access the Axis2D.Title property.

View Example: How to Create and Customize an Axis Title

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

namespace AxisTitle {
    public partial class Form1 : Form {
        public Form1() {
            InitializeComponent();
        }
        private void Form1_Load(object sender, EventArgs e) {
        // ...
            // Cast the chart's diagram to the XYDiagram type, to access its axes.
            XYDiagram diagram = chartControl1.Diagram as XYDiagram;

            // Customize the appearance of the X-axis title.
            diagram.AxisX.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisX.Title.Alignment = StringAlignment.Center;
            diagram.AxisX.Title.Text = "<i>X-axis</i> <color=violet>Title</color>";
            diagram.AxisX.Title.TextColor = Color.Red;
            diagram.AxisX.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisX.Title.DXFont = new DXFont("Tahoma", 14, DXFontStyle.Bold);

            // Customize the appearance of the Y-axis title.
            diagram.AxisY.Title.Visibility = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.Alignment = StringAlignment.Center;
            diagram.AxisY.Title.Text = "Y-axis Title";
            diagram.AxisY.Title.TextColor = Color.Blue;
            diagram.AxisY.Title.EnableAntialiasing = DevExpress.Utils.DefaultBoolean.True;
            diagram.AxisY.Title.DXFont = new DXFont("Tahoma", 14, DXFontStyle.Bold);

            // Add the chart to the form.
            chartControl1.Dock = DockStyle.Fill;
            this.Controls.Add(chartControl1);
        }
    }
}

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the Alignment property.

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