corelibraries-devexpress-dot-xtracharts-dot-titlebase-c3041083.md
Gets or sets the font used to display the title’s text.
Namespace : DevExpress.XtraCharts
Assembly : DevExpress.XtraCharts.v25.2.dll
NuGet Package : DevExpress.Charts
[Browsable(false)]
public Font Font { get; set; }
<Browsable(False)>
Public Property Font As Font
| Type | Description |
|---|---|
| Font |
A Font object that specifies the font used to display the title’s text.
|
Important
Use the TitleBase.DXFont property instead of Font to specify the font of the title’s text.
Use the Title.Text property to specify the text of the title.
This example demonstrates how to access an axis title at runtime.
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);
}
}
}
Imports System
Imports System.Drawing
Imports System.Windows.Forms
Imports DevExpress.Drawing
Imports DevExpress.XtraCharts
Namespace AxisTitle
Public Partial Class Form1
Inherits Form
' ...
' Hide the legend (if necessary).
chartControl1.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False
' Cast the chart's diagram to the XYDiagram type, to access its axes.
Dim diagram As XYDiagram = TryCast(chartControl1.Diagram, 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
Me.Controls.Add(chartControl1)
End Sub
End Class
End Namespace
The following code snippets (auto-collected from DevExpress Examples) contain references to the Font 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.
asp-net-web-forms-web-chart-control-create-drill-down-chart/CS/DrillDownChart/WebForm1.aspx.cs#L15
if (diagram != null) {
diagram.AxisX.Label.Font = new Font(diagram.AxisX.Label.Font, FontStyle.Underline);
}
reporting-winforms-create-report-dynamically-and-bind-it-to-dataset/CS/Form1.cs#L221
(chart.Diagram as XYDiagram).AxisX.Label.Angle = 20;
(chart.Diagram as XYDiagram).AxisX.Label.Font = new Font(
"Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point, ((byte)(204)));
asp-net-web-forms-web-chart-control-create-drill-down-chart/VB/DrillDownChart/WebForm1.aspx.vb#L17
If diagram IsNot Nothing Then
diagram.AxisX.Label.Font = New Font(diagram.AxisX.Label.Font, FontStyle.Underline)
End If
reporting-winforms-create-report-dynamically-and-bind-it-to-dataset/VB/Form1.vb#L217
TryCast(chart.Diagram, XYDiagram).AxisX.Label.Angle = 20
TryCast(chart.Diagram, XYDiagram).AxisX.Label.Font = New Font("Tahoma", 9.75F, FontStyle.Regular, GraphicsUnit.Point, (CByte(204)))
See Also