Back to Devexpress

ChartTitle Class

corelibraries-devexpress-dot-xtracharts-5c4ff280.md

latest4.9 KB
Original Source

ChartTitle Class

Represents an individual chart title.

Namespace : DevExpress.XtraCharts

Assembly : DevExpress.XtraCharts.v25.2.dll

NuGet Package : DevExpress.Charts

Declaration

csharp
public class ChartTitle :
    DockableTitle,
    ISupportID
vb
Public Class ChartTitle
    Inherits DockableTitle
    Implements ISupportID

The following members return ChartTitle objects:

Remarks

The ChartTitle class implements the functionality of an individual chart title in a chart control.

A chart control’s titles are stored within the ChartControl.Titles collection, represented by an instance of the ChartTitleCollection class. This collection provides standard means for manipulating its items such as adding, removing and accessing them. A particular chart title is available via the ChartTitleCollection.Item property of the collection using indexer notation.

For more information, refer to Chart Titles.

Example

This example demonstrates how chart titles can be accessed and customized at runtime.

csharp
// Create chart titles.
ChartTitle chartTitle1 = new ChartTitle();
ChartTitle chartTitle2 = new ChartTitle();

// Define the text for the titles.
chartTitle1.Text = "<i>Basic</i> <b>HTML</b> <u>is</u> <color=blue>supported</color>.";
chartTitle2.Text = "The capability to word-wrap is available for chart titles.";

chartTitle2.WordWrap = true;
chartTitle2.MaxLineCount = 2;

// Define the alignment of the titles.
chartTitle1.Alignment = StringAlignment.Center;
chartTitle2.Alignment = StringAlignment.Near;

// Place the titles where it's required.
chartTitle1.Dock = ChartTitleDockStyle.Top;
chartTitle2.Dock = ChartTitleDockStyle.Bottom;

// Customize a title's appearance.
chartTitle1.Antialiasing = true;
chartTitle1.Font = new Font("Tahoma", 14, FontStyle.Bold);
chartTitle1.TextColor = Color.Red;
chartTitle1.Indent = 10;

// Add the titles to the chart.
chartControl1.Titles.AddRange(new ChartTitle[] {
chartTitle1,
chartTitle2});
vb
' Create chart titles.
Dim chartTitle1 As New ChartTitle()
Dim chartTitle2 As New ChartTitle()

' Define the text for the titles.
chartTitle1.Text = "<i>Basic</i> <b>HTML</b> <u>is</u> <color=blue>supported</color>."
chartTitle2.Text = "The capability to word-wrap is available for chart titles."

chartTitle2.WordWrap = True
chartTitle2.MaxLineCount = 2

' Define the alignment of the titles.
chartTitle1.Alignment = StringAlignment.Center
chartTitle2.Alignment = StringAlignment.Near

' Place the titles where it's required.
chartTitle1.Dock = ChartTitleDockStyle.Top
chartTitle2.Dock = ChartTitleDockStyle.Bottom

' Customize a title's appearance.
chartTitle1.Antialiasing = True
chartTitle1.Font = New Font("Tahoma", 14, FontStyle.Bold)
chartTitle1.TextColor = Color.Red
chartTitle1.Indent = 10

' Add the titles to the chart.
chartControl1.Titles.AddRange(New ChartTitle() { chartTitle1, chartTitle2})

Inheritance

Object ChartElement TitleBase Title MultilineTitle AlignedTitle DockableTitle ChartTitle

See Also

ChartTitle Members

Titles

ChartTitleCollection

Item[Int32]

Chart Titles

DevExpress.XtraCharts Namespace