Chart Title in PowerPoint
2 Dec 20248 minutes to read
Chart title is a concise description at the top of a chart, offering context and clarity for the data displayed. Using Presentation, you can customize the chart title in the chart.
Set the Chart Title Name
The following code snippet illustrates how to set the chart title name.
// Set the chart title.
chart.ChartTitle = "Purchase Details";
// Set the chart title.
chart.ChartTitle = "Purchase Details";
' Set the chart title.
chart.ChartTitle = "Purchase Details"
Customize the Chart Title Area
The following code snippet illustrates how to customize the chart title area.
// Customize chart title area.
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Bold = true;
chart.ChartTitleArea.Color = OfficeKnownColors.Red;
chart.ChartTitleArea.Underline = OfficeUnderline.DashLong;
chart.ChartTitleArea.Size = 14;
// Customize chart title area.
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Bold = true;
chart.ChartTitleArea.Color = OfficeKnownColors.Red;
chart.ChartTitleArea.Underline = OfficeUnderline.DashLong;
chart.ChartTitleArea.Size = 14;
' Customize chart title area.
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Bold = True
chart.ChartTitleArea.Color = OfficeKnownColors.Red
chart.ChartTitleArea.Underline = OfficeUnderline.DashLong
chart.ChartTitleArea.Size = 14
Resize the Chart Title Area
The following code snippet illustrates how to resize the chart title area.
//Manually resizing chart title area using Layout.
chart.ChartTitleArea.Layout.Top = 10;
chart.ChartTitleArea.Layout.Left = 10;
//Manually resizing chart title area using Manual Layout.
chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005;
chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26;
//Manually resizing chart title area using Layout.
chart.ChartTitleArea.Layout.Top = 10;
chart.ChartTitleArea.Layout.Left = 10;
//Manually resizing chart title area using Manual Layout.
chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005;
chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26;
' Manually resizing chart title area using Layout.
chart.ChartTitleArea.Layout.Top = 10
chart.ChartTitleArea.Layout.Left = 10
' Manually resizing chart title area using Manual Layout.
chart.ChartTitleArea.Layout.ManualLayout.Top = 0.005
chart.ChartTitleArea.Layout.ManualLayout.Left = 0.26
The complete code snippet illustrating the above options is shown below.
FileStream fileStreamPath = new FileStream("Data/Template.pptx", FileMode.Open, FileAccess.Read, FileShare.ReadWrite);
//Open an existing PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open(fileStreamPath))
{
//Gets the first slide.
ISlide slide = pptxDoc.Slides[0];
//Gets the chart in slide.
IPresentationChart chart = slide.Shapes[0] as IPresentationChart;
// Set the chart title.
chart.ChartTitle = "Purchase Details";
// Customize chart title area.
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Bold = true;
chart.ChartTitleArea.Color = OfficeKnownColors.Black;
chart.ChartTitleArea.Underline = OfficeUnderline.WavyHeavy;
//Manually resizing chart title area using Layout.
chart.ChartTitleArea.Layout.Left = 5;
//Enable legend.
chart.HasLegend = true;
chart.Legend.Position = OfficeLegendPosition.Right;
using (FileStream outputStream = new FileStream("Result.pptx", FileMode.Create, FileAccess.ReadWrite, FileShare.ReadWrite))
{
//Save the PowerPoint Presentation.
pptxDoc.Save(outputStream);
}
}
//Open an existing PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open("Template.pptx"))
{
//Gets the first slide.
ISlide slide = pptxDoc.Slides[0];
//Gets the chart in slide.
IPresentationChart chart = slide.Shapes[0] as IPresentationChart;
// Set the chart title.
chart.ChartTitle = "Purchase Details";
// Customize chart title area.
chart.ChartTitleArea.FontName = "Calibri";
chart.ChartTitleArea.Bold = true;
chart.ChartTitleArea.Color = OfficeKnownColors.Black;
chart.ChartTitleArea.Underline = OfficeUnderline.WavyHeavy;
//Manually resizing chart title area using Layout.
chart.ChartTitleArea.Layout.Left = 5;
//Enable legend.
chart.HasLegend = true;
chart.Legend.Position = OfficeLegendPosition.Right;
//Save the PowerPoint Presentation.
pptxDoc.Save("Result.pptx");
}
Using pptxDoc As IPresentation = Presentation.Open("Template.pptx")
' Gets the first slide.
Dim slide As ISlide = pptxDoc.Slides(0)
' Gets the chart in the slide.
Dim chart As IPresentationChart = TryCast(slide.Shapes(0), IPresentationChart)
' Set the chart title.
chart.ChartTitle = "Purchase Details"
' Customize chart title area.
chart.ChartTitleArea.FontName = "Calibri"
chart.ChartTitleArea.Bold = True
chart.ChartTitleArea.Color = OfficeKnownColors.Black
chart.ChartTitleArea.Underline = OfficeUnderline.WavyHeavy
' Manually resize the chart title area using Layout.
chart.ChartTitleArea.Layout.Left = 5
' Enable legend.
chart.HasLegend = True
chart.Legend.Position = OfficeLegendPosition.Right
' Save the PowerPoint presentation.
pptxDoc.Save("Result.pptx")
End Using