How to: Add a Title to an Axis
- 2 minutes to read
This example demonstrates how to access an axis title at runtime.
// Cast the chart's diagram to the XYDiagram type, to access its axes. XYDiagram diagram = (XYDiagram)chartControl1.Diagram; // Customize the appearance of the X-axis title. diagram.AxisX.Title.Visible = true; diagram.AxisX.Title.Alignment = StringAlignment.Center; diagram.AxisX.Title.Text = "X-axis Title"; diagram.AxisX.Title.TextColor = Color.Red; diagram.AxisX.Title.Antialiasing = true; diagram.AxisX.Title.Font = new Font("Tahoma", 14, FontStyle.Bold); // Customize the appearance of the Y-axis title. diagram.AxisY.Title.Visible = true; diagram.AxisY.Title.Alignment = StringAlignment.Center; diagram.AxisY.Title.Text = "Y-axis Title"; diagram.AxisY.Title.TextColor = Color.Blue; diagram.AxisY.Title.Antialiasing = true; diagram.AxisY.Title.Font = new Font("Tahoma", 14, FontStyle.Bold);
The result is shown in the following image.
A complete sample project is available in the DevExpress Code Examples database at https://supportcenter.devexpress.com/ticket/details/e1366/how-to-create-and-customize-an-axis-title.