Chart Plot Area in PowerPoint

29 Jul 202610 minutes to read

The plot area refers to the region that represents the plotted data in a chart. Using Presentation, you can customize the plot area in the chart.

Customize the Border

The following code snippet illustrates how to modify the border of the plot area.

//Format the plot area.
IOfficeChartFrameFormat chartPlotArea = chart.PlotArea;
//Plot area border settings - line pattern, color, weight.
chartPlotArea.Border.LinePattern = OfficeChartLinePattern.Solid;
chartPlotArea.Border.LineColor = Syncfusion.Drawing.Color.Blue;
chartPlotArea.Border.LineWeight = OfficeChartLineWeight.Hairline;
//Format the plot area.
IOfficeChartFrameFormat chartPlotArea = chart.PlotArea;
//Plot area border settings - line pattern, color, weight.
chartPlotArea.Border.LinePattern = OfficeChartLinePattern.Solid;
chartPlotArea.Border.LineColor = Color.Blue;
chartPlotArea.Border.LineWeight = OfficeChartLineWeight.Hairline;
' Format the plot area.
Dim chartPlotArea As IOfficeChartFrameFormat = chart.PlotArea
' Plot area border settings - line pattern, color, weight.
chartPlotArea.Border.LinePattern = OfficeChartLinePattern.Solid
chartPlotArea.Border.LineColor = Color.Blue
chartPlotArea.Border.LineWeight = OfficeChartLineWeight.Hairline

Customize the Fill

The following code snippet illustrates how to apply a fill color to the plot area.

//Set fill type and color.
 chartPlotArea.Fill.FillType = OfficeFillType.Gradient;
 chartPlotArea.Fill.GradientColorType = OfficeGradientColor.TwoColor;
 chartPlotArea.Fill.BackColor = Syncfusion.Drawing.Color.FromArgb(205, 217, 234);
 chartPlotArea.Fill.ForeColor = Syncfusion.Drawing.Color.White;
//Set fill type and color.
 chartPlotArea.Fill.FillType = OfficeFillType.Gradient;
 chartPlotArea.Fill.GradientColorType = OfficeGradientColor.TwoColor;
 chartPlotArea.Fill.BackColor = Color.FromArgb(205, 217, 234);
 chartPlotArea.Fill.ForeColor = Color.White;
' Set fill type and color.
 chartPlotArea.Fill.FillType = OfficeFillType.Gradient
 chartPlotArea.Fill.GradientColorType = OfficeGradientColor.TwoColor
 chartPlotArea.Fill.BackColor = Color.FromArgb(205, 217, 234)
 chartPlotArea.Fill.ForeColor = Color.White

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;

    //Plot Area.
    IOfficeChartFrameFormat chartPlotArea = chart.PlotArea;

    //Plot area border settings - line pattern, color, weight.
    chartPlotArea.Border.LinePattern = OfficeChartLinePattern.Solid;
    chartPlotArea.Border.LineColor = Syncfusion.Drawing.Color.Blue;
    chartPlotArea.Border.LineWeight = OfficeChartLineWeight.Hairline;

    //Set fill type and color.
    chartPlotArea.Fill.FillType = OfficeFillType.Gradient;
    chartPlotArea.Fill.GradientColorType = OfficeGradientColor.TwoColor;
    chartPlotArea.Fill.BackColor = Syncfusion.Drawing.Color.FromArgb(205, 217, 234);
    chartPlotArea.Fill.ForeColor = Syncfusion.Drawing.Color.White;

    //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 slide.
    IPresentationChart chart = slide.Shapes[0] as IPresentationChart;

    //Plot Area.
    IOfficeChartFrameFormat chartPlotArea = chart.PlotArea;

    //Plot area border settings - line pattern, color, weight.
    chartPlotArea.Border.LinePattern = OfficeChartLinePattern.Solid;
    chartPlotArea.Border.LineColor = Syncfusion.Drawing.Color.Blue;
    chartPlotArea.Border.LineWeight = OfficeChartLineWeight.Hairline;

    //Set fill type and color.
    chartPlotArea.Fill.FillType = OfficeFillType.Gradient;
    chartPlotArea.Fill.GradientColorType = OfficeGradientColor.TwoColor;
    chartPlotArea.Fill.BackColor = Syncfusion.Drawing.Color.FromArgb(205, 217, 234);
    chartPlotArea.Fill.ForeColor = Syncfusion.Drawing.Color.White;

    //Save the PowerPoint Presentation.
    pptxDoc.Save("Result.pptx");
}
' Open an existing PowerPoint presentation.
Using pptxDoc As IPresentation = Presentation.Open("Template.pptx")
    ' Get the first slide.
    Dim slide As ISlide = pptxDoc.Slides(0)
    ' Get the chart in the slide.
    Dim chart As IPresentationChart = TryCast(slide.Shapes(0), IPresentationChart)

    ' Access the chart's plot area.
    Dim chartPlotArea As IOfficeChartFrameFormat = chart.PlotArea

    ' Set plot area border settings - line pattern, color, weight.
    chartPlotArea.Border.LinePattern = OfficeChartLinePattern.Solid
    chartPlotArea.Border.LineColor = Color.Blue
    chartPlotArea.Border.LineWeight = OfficeChartLineWeight.Hairline

    ' Set plot area fill type and color.
    chartPlotArea.Fill.FillType = OfficeFillType.Gradient
    chartPlotArea.Fill.GradientColorType = OfficeGradientColor.TwoColor
    chartPlotArea.Fill.BackColor = Color.FromArgb(205, 217, 234)
    chartPlotArea.Fill.ForeColor = Color.White

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

You can download a complete working sample from GitHub.

Add Image in Plot Area

The following code snippet illustrates how to add an image to the plot area.

//Append an image to the chart plot area.
FileStream imageStream = new FileStream("Data/Image.png", FileMode.Open, FileAccess.Read);
Image image = Image.FromStream(imageStream);
chartPlotArea.Fill.UserPicture(image, "image");
//Append an image to the chart plot area.
chartPlotArea.Fill.UserPicture("Image.png");
' Append an image to the chart plot area.
chartPlotArea.Fill.UserPicture("Image.png")

Set the Transparency Level

The following code snippet illustrates how to apply transparency to the plot area.

// Set the transparency of the plot area.
chartPlotArea.Fill.Transparency = 0.5;
// Set the transparency of the plot area.
chartPlotArea.Fill.Transparency = 0.5;
' Set the transparency of the plot area.
chartPlotArea.Fill.Transparency = 0.5

NOTE

Transparency is only applicable when FillType is set to SolidColor. The fill’s transparency is represented as a floating-point value ranging from 0.0 (Fully Opaque) to 1.0 (Fully Transparent).

Set the Position of the Plot Area

The following code snippet illustrates how to position the plot area in the chart.

//Sets position for plot area.
chartPlotArea.Layout.LeftMode = LayoutModes.auto;
chartPlotArea.Layout.TopMode = LayoutModes.factor;
chartPlotArea.Layout.LayoutTarget = LayoutTargets.outer;
//Sets position for plot area.
chartPlotArea.Layout.LeftMode = LayoutModes.auto;
chartPlotArea.Layout.TopMode = LayoutModes.factor;
chartPlotArea.Layout.LayoutTarget = LayoutTargets.outer;
' Sets position for plot area.
chartPlotArea.Layout.LeftMode = LayoutModes.auto
chartPlotArea.Layout.TopMode = LayoutModes.factor
chartPlotArea.Layout.LayoutTarget = LayoutTargets.outer

See Also