ActiveReports 13
Chart Titles and Footers
ActiveReports 13 > ActiveReports User Guide > Concepts > Section Report Concepts > Section Report Toolbox > Chart > Chart Appearance > Chart Control Items > Chart Titles and Footers

The Chart control allows you to add custom titles to your charts. The Titles collection is accessible from the Chart object. With the ability to add as many titles as needed, dock them to any side of a chart area, change all of the font properties, add borders and shadows, make the background look the way you want it, and change the location of the text, you can easily make your titles look the way you want them to look.

The following code demonstrates creating header and footer titles, setting their properties, and adding them to the titles collection at run time.

  1. In design view of the report, double-click the section where you placed your chart. This creates a Format event handling method for the section.
  2. Add code to the handler to create header and footer titles.

To write the code in Visual Basic.NET

Visual Basic.NET code. Paste INSIDE the section Format event.
Copy Code
' create the header and footer titles
Dim tHeader As New GrapeCity.ActiveReports.Chart.Title
Dim tFooter As New GrapeCity.ActiveReports.Chart.Title

' set the properties for the header
tHeader.Alignment = Chart.Alignment.Center
tHeader.Backdrop = New GrapeCity.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle)
tHeader.Border = New GrapeCity.ActiveReports.Chart.Border(New GrapeCity.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.DimGray), 3)
tHeader.DockArea = Me.ChartControl1.ChartAreas(0)
tHeader.Docking = Chart.DockType.Top
tHeader.Font = New GrapeCity.ActiveReports.Chart.FontInfo(System.Drawing.Color.White, New System.Drawing.Font("Arial", 25.0F))
tHeader.Text = "Chart Title"
tHeader.Visible = True

' set the properties for the footer
tFooter.Alignment = Chart.Alignment.Center
tFooter.Backdrop = New GrapeCity.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle)
tFooter.Border = New GrapeCity.ActiveReports.Chart.Border(New GrapeCity.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Indigo), 0, System.Drawing.Color.Black)
tFooter.DockArea = Me.ChartControl1.ChartAreas(0)
tFooter.Docking = Chart.DockType.Bottom
tFooter.Font = New GrapeCity.ActiveReports.Chart.FontInfo(System.Drawing.Color.DimGray, New System.Drawing.Font("Arial", 12.0F, System.Drawing.FontStyle.Bold))
tFooter.Text = "Chart Footer"
tFooter.Visible = True

' add the header and footer titles to the titles collection
Me.ChartControl1.Titles.AddRange(New GrapeCity.ActiveReports.Chart.Title() {tHeader, tFooter})

To write the code in C#

C# code. Paste INSIDE the section Format event.
Copy Code
// create the header and footer titles
GrapeCity.ActiveReports.Chart.Title tHeader = new GrapeCity.ActiveReports.Chart.Title();
GrapeCity.ActiveReports.Chart.Title tFooter = new GrapeCity.ActiveReports.Chart.Title();

// set the properties for the header
tHeader.Alignment = Chart.Alignment.Center;
tHeader.Backdrop = new GrapeCity.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle);
tHeader.Border = new GrapeCity.ActiveReports.Chart.Border(new GrapeCity.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.DimGray), 3);
tHeader.DockArea = this.ChartControl1.ChartAreas[0];
tHeader.Docking = Chart.DockType.Top;
tHeader.Font = new GrapeCity.ActiveReports.Chart.FontInfo(System.Drawing.Color.White, new System.Drawing.Font("Arial", 25F));
tHeader.Text = "Chart Title";
tHeader.Visible = true;

// set the properties for the footer
tFooter.Alignment = Chart.Alignment.Center;
tFooter.Backdrop = new GrapeCity.ActiveReports.Chart.Graphics.Backdrop(System.Drawing.Color.Thistle);
tFooter.Border = new GrapeCity.ActiveReports.Chart.Border(new GrapeCity.ActiveReports.Chart.Graphics.Line(System.Drawing.Color.Indigo), 0, System.Drawing.Color.Black);
tFooter.DockArea = this.ChartControl1.ChartAreas[0];
tFooter.Docking = Chart.DockType.Bottom;
tFooter.Font = new GrapeCity.ActiveReports.Chart.FontInfo(System.Drawing.Color.DimGray, new System.Drawing.Font("Arial", 12F, System.Drawing.FontStyle.Bold));
tFooter.Text = "Chart Footer";
tFooter.Visible = true;

// add the header and footer titles to the titles collection
this.ChartControl1.Titles.AddRange(new GrapeCity.ActiveReports.Chart.Title[] {tHeader,tFooter});
See Also

Charts