Free Support Forum -

Leader lines not visible in pie chart in Powerpoint

I am using below code to generate pie chart, but leaderlines are not showing and chart label sits just outside the pie chart. Kindly help:
ISlide slides = pres.Slides[1];

        // Add chart with default data
        IChart chart = slides.Shapes.AddChart(ChartType.Pie, 247, 136, 375, 375);
        chart.ChartTitle.AddTextFrameForOverriding("Sample Title");
        chart.ChartTitle.TextFrameForOverriding.TextFrameFormat.CenterText = NullableBool.True;
        chart.ChartTitle.Height = 20;
        chart.HasTitle = true;

        // Set first series to Show Values
        chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.ShowValue = true;

        // Setting the index of chart data sheet
        int defaultWorksheetIndex = 0;

        // Getting the chart data worksheet
        IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

        // Delete default generated series and categories

        // Adding new categories
        chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, "Category1"));
        chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, "Category2"));
        chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, "Category3"));
        IChartSeries series = chart.ChartData.Series.Add(fact.GetCell(0, 0, 1), chart.Type);

        // Now populating series data
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 1, 1, 30));
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 2, 1, 40));
        series.DataPoints.AddDataPointForPieSeries(fact.GetCell(defaultWorksheetIndex, 3, 1, 30));

        chart.ChartData.SeriesGroups[0].IsColorVaried = true;

        IChartDataPoint point = series.DataPoints[0];
        point.Format.Fill.FillType = FillType.Solid;
        point.Format.Fill.SolidFillColor.Color = Color.Green;
        point.Format.Line.FillFormat.FillType = FillType.Solid;
        point.Format.Line.FillFormat.SolidFillColor.Color = Color.Green;
        point.Format.Line.Width = 1.0;
        point.Format.Line.Style = LineStyle.ThinThin;
        point.Format.Line.DashStyle = LineDashStyle.Solid;

        IChartDataPoint point1 = series.DataPoints[1];
        point1.Format.Fill.FillType = FillType.Solid;
        point1.Format.Fill.SolidFillColor.Color = Color.DarkGreen;

        // Setting Sector border
        point1.Format.Line.FillFormat.FillType = FillType.Solid;
        point1.Format.Line.FillFormat.SolidFillColor.Color = Color.DarkGreen;
        point1.Format.Line.Width = 1.0;
        point1.Format.Line.Style = LineStyle.ThinThin;
        point1.Format.Line.DashStyle = LineDashStyle.Solid;

        IChartDataPoint point2 = series.DataPoints[2];
        point2.Format.Fill.FillType = FillType.Solid;
        point2.Format.Fill.SolidFillColor.Color = Color.DarkOliveGreen;

        // Setting Sector border
        point2.Format.Line.FillFormat.FillType = FillType.Solid;
        point2.Format.Line.FillFormat.SolidFillColor.Color = Color.DarkOliveGreen;
        point2.Format.Line.Width = 1.0;
        point2.Format.Line.Style = LineStyle.ThinThin;
        point2.Format.Line.DashStyle = LineDashStyle.Solid;

        // Create custom labels for each of categories for new series
        IDataLabel lbl1 = series.DataPoints[0].Label;

        // lbl.ShowCategoryName = true;
        //lbl1.DataLabelFormat.ShowValue = true;
        lbl1.DataLabelFormat.ShowPercentage = true;
         lbl1.DataLabelFormat.ShowCategoryName = true;
         lbl1.DataLabelFormat.TextFormat.PortionFormat.FontHeight = 8;
        lbl1.DataLabelFormat.Position = LegendDataLabelPosition.OutsideEnd;

        IDataLabel lbl2 = series.DataPoints[1].Label;
        lbl2.DataLabelFormat.ShowPercentage = true;
        lbl2.DataLabelFormat.ShowCategoryName = true;
        lbl2.DataLabelFormat.TextFormat.PortionFormat.FontHeight = 8;
        lbl2.DataLabelFormat.Position = LegendDataLabelPosition.OutsideEnd;

        IDataLabel lbl3 = series.DataPoints[2].Label;
        //lbl3.DataLabelFormat.ShowSeriesName = true;
        lbl3.DataLabelFormat.ShowPercentage = true;
        lbl3.DataLabelFormat.ShowCategoryName = true;
        lbl3.DataLabelFormat.TextFormat.PortionFormat.FontHeight = 8;
        lbl3.DataLabelFormat.Position = LegendDataLabelPosition.OutsideEnd;

        // Showing Leader Lines for Chart
        series.Labels.DefaultDataLabelFormat.ShowValue = true;
        series.Labels.DefaultDataLabelFormat.ShowLeaderLines = true;
        chart.HasLegend = false;
        // Setting Rotation Angle for Pie Chart Sectors
        chart.ChartData.SeriesGroups[0].FirstSliceAngle = 180;

Thank you for the issue description.

Please share the presentation file you are using to add the chart.
Also, please specify the version of Aspose.Slides you are using and share screenshots with expected and actual results.

Presentation is just blank presentation.
Presentation pres = new Presentation();

Attached images for Chart generated and expected.ChartExpected.PNG (27.9 KB)
ChartGenerated.PNG (26.0 KB)

Using Aspose.Slides version 21.3.0

Kindly help.

Thank you for the additional information. I reproduced the problem and received the same results. I have logged the issue in our tracking system with ID SLIDESNET-42500 to investigate further. You will be notified when it is fixed.

Our development team investigated the issue and found no errors. Appearing leader lines depends on the distance between the data label and the edge of the pie chart. You should move the labels farther from the edge to make them shown.
More details: Chart Data Label

Hi Andrey,
The link you shared is for Bar chart. We do not have Axes for Pie chart. Please share code sample to programmatically move labels from Edge of pie chart to make them Visible. We have numerous pie charts for our Power point document from Aspose and it will greatly help.

Thanks in advance.

Please try to change the locations of data labels as below:

point1.Label.X = 0.1f;
point1.Label.Y = -0.1f;

Result: chart-out.png (14.4 KB)

API Reference: IDataLabel Interface, ILayoutable Interface
We will improve the documentation. Thank you for your patience.