How to add multiple Chart Titles?
Essential Chart supports displaying multiple chart titles. We can add multiple charts at design time and also at run time.
Titles can be added using Titles property under chart control. It opens a Titles Collection Editor where we can add, remove and customize the title.
The sample screen shot illustrates this.
Chart Titles can be added at run time using ChartTitle class.
C#
// Creating a new title
ChartTitle title1 = new ChartTitle();
title1.Text = "Marketing";
title1.Position = ChartDock.Bottom;
// Adding into Chart control
this.chartControl1.Titles.Add(title1);
VB
' Specifying Chart Title
Me.ChartControl1.Titles(0).ForeColor = Color.MidnightBlue
Dim title1 As ChartTitle = New ChartTitle()
title1.Text = "Marketing"
title1.Position = ChartDock.Bottom
' Adding into Chart Control
Me.ChartControl1.Titles.Add(title1)
Each title can be customizied individually by setting display settings. Border can be displayed by setting ShowBorder property as true.
C#
// Customizing Title
this.chartControl1.Titles[1].Alignment = ChartAlignment.Center;
this.chartControl1.Titles[1].BackColor = Color.AliceBlue;
this.chartControl1.Titles[1].ForeColor = Color.Crimson;
this.chartControl1.Titles[1].ShowBorder = true;
this.chartControl1.Titles[1].Border.ForeColor = Color.Green;
this.chartControl1.Titles[1].Border.DashStyle = DashStyle.Solid;
this.chartControl1.Titles[1].Border.Width = 1f;
this.chartControl1.Titles[1].Font = new Font("TimesNewRoman", 12.0f);
VB
' Customizing Title
Me.ChartControl1.Titles(1).Alignment = ChartAlignment.Center
Me.ChartControl1.Titles(1).BackColor = Color.AliceBlue
Me.ChartControl1.Titles(1).ForeColor = Color.Crimson
Me.ChartControl1.Titles(1).ShowBorder = True
Me.ChartControl1.Titles(1).Border.ForeColor = Color.Green
Me.ChartControl1.Titles(1).Border.DashStyle = DashStyle.Solid
Me.ChartControl1.Titles(1).Border.Width = 1.0F
Me.ChartControl1.Titles(1).Font = New Font("TimesNewRoman", 12.0F)