Add Shadow Effect to Chart DataLabels in PowerPoint in C#

Adding shadow effect is one of the good ways to make a data label stand out on your chart. This article is going to show you how to add shadow effect to a chart data label in PowerPoint using Spire.Presentation.

Detail steps:

Step 1: Initialize a Presentation object and load the PowerPoint file.

Presentation ppt = new Presentation();
ppt.LoadFromFile(@"test.pptx");

Step 2: Get the chart.

IChart chart = ppt.Slides[0].Shapes[0] as IChart;

Step 3: Add a data label to the first chart series.

ChartDataLabelCollection dataLabels = chart.Series[0].DataLabels;            
ChartDataLabel Label = dataLabels.Add();
Label.LabelValueVisible = true;

Step 4: Add outer shadow effect to the data label.

Label.Effect.OuterShadowEffect = new OuterShadowEffect();
//Set shadow color
Label.Effect.OuterShadowEffect.ColorFormat.Color = Color.Yellow;
//Set blur
Label.Effect.OuterShadowEffect.BlurRadius = 5;
//Set distance
Label.Effect.OuterShadowEffect.Distance = 10;
//Set angle
Label.Effect.OuterShadowEffect.Direction = 90f;

Step 5: Save the file.

ppt.SaveToFile("Shadow.pptx", FileFormat.Pptx2010);

Screenshot:

Add Shadow Effect to Chart DataLabels in PowerPoint in C#

Full code:

using System.Drawing;
using Spire.Presentation;
using Spire.Presentation.Charts;
using Spire.Presentation.Collections;
using Spire.Presentation.Drawing;

namespace Add_Shadow_Effect_to_Chart_Datalabel
{
    class Program
    {
        static void Main(string[] args)
        {
            //Initialize a Presentation object
            Presentation ppt = new Presentation();
            //Load the PowerPoint file
            ppt.LoadFromFile(@"test.pptx");

            //Get the chart
            IChart chart = ppt.Slides[0].Shapes[0] as IChart;

            //Add a data label to the first chart series
            ChartDataLabelCollection dataLabels = chart.Series[0].DataLabels;            
            ChartDataLabel Label = dataLabels.Add();
            Label.LabelValueVisible = true;
            
            //Add outer shadow effect to the data label

            Label.Effect.OuterShadowEffect = new OuterShadowEffect();
            //Set shadow color
            Label.Effect.OuterShadowEffect.ColorFormat.Color = Color.Yellow;
            //Set blur
            Label.Effect.OuterShadowEffect.BlurRadius = 5;
            //Set distance
            Label.Effect.OuterShadowEffect.Distance = 10;
            //Set angle
            Label.Effect.OuterShadowEffect.Direction = 90f;            

            //Save the file
            ppt.SaveToFile("Shadow.pptx", FileFormat.Pptx2010);
        }
    }
}