Chart Title in PowerPoint

28 Jul 20268 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 by:

  • Setting the chart title text.
  • Customizing the chart title area (font, color, size, weight, underline, and so on).
  • Positioning the chart title area within the chart.

NOTE

For prerequisites (installing the NuGet packages, required namespaces, and creating a chart), refer to the Getting Started and NuGet Packages Required documentation.

Set the Chart Title Name

The following code snippet illustrates how to set the chart title name on a chart named chart.

// 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. The OfficeKnownColors enum exposes a wide range of named colors (for example, Red, Black, Blue), and the OfficeUnderline enum defines the supported underline styles (for example, DashLong, WavyHeavy, None).

// Customize the 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 the 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

Position the Chart Title Area

The following code snippet illustrates how to position the chart title area. The Layout properties (Top, Left, Width, Height) accept values in points, whereas the ManualLayout properties accept fractional values in the range 0–1 relative to the chart area.

// Position the chart title area using Layout (values in points).
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;
' Position the chart title area using Layout (values in points).
chart.ChartTitleArea.Layout.Top = 10
chart.ChartTitleArea.Layout.Left = 10

' Position the chart title area using Manual Layout (values are fractions of the chart area, 0 to 1).
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.

// Open an existing PowerPoint Presentation.
using (IPresentation pptxDoc = Presentation.Open("Data/Template.pptx"))
{
    // Gets the first slide.
    ISlide slide = pptxDoc.Slides[0];
    // Gets the chart in the slide.
    IPresentationChart chart = slide.Shapes[0] as IPresentationChart;

    // Set the chart title.
    chart.ChartTitle = "Purchase Details";

    // Customize the 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;

    // Position the chart title area using Layout (values in points).
    chart.ChartTitleArea.Layout.Top = 10;
    chart.ChartTitleArea.Layout.Left = 10;

    // Save the PowerPoint Presentation.
    pptxDoc.Save("Result.pptx");
}
// 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 the slide.
    IPresentationChart chart = slide.Shapes[0] as IPresentationChart;

    // Set the chart title.
    chart.ChartTitle = "Purchase Details";

    // Customize the 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;

    // Position the chart title area using Layout (values in points).
    chart.ChartTitleArea.Layout.Top = 10;
    chart.ChartTitleArea.Layout.Left = 10;

    // Save the PowerPoint Presentation.
    pptxDoc.Save("Result.pptx");
}
' Open an existing PowerPoint Presentation.
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 the 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

    ' Position the chart title area using Layout (values in points).
    chart.ChartTitleArea.Layout.Top = 10
    chart.ChartTitleArea.Layout.Left = 10

    ' Save the PowerPoint presentation.
    pptxDoc.Save("Result.pptx")
End Using

You can download a complete working sample from GitHub.

See Also