We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Pie Chart Labels Spacing


I’m trying to get some pie chart data labels to be spaced properly, but they are getting generated in a small area and making them illegible. We’re trying the fairly recent “IsNeverOverlap” value to true but that doesn’t seem to be helping.

image.png (18.5 KB)

Sample code:

        Sheet.Charts.Add(Aspose.Cells.Charts.ChartType.Pie, 18,0,37,5);
        var dest = Sheet.Charts[0];
        // general chart defaults 
        dest.ChartArea.Area.ForegroundColor = Color.White;
        dest.PlotArea.Area.ForegroundColor  = Color.White;
        dest.ChartArea.Border.Weight = Aspose.Cells.Drawing.WeightType.SingleLine;
        dest.ChartArea.Border.Color = Color.Black;
        dest.Title.Font.IsBold = true;

        dest.Title.Text = "Revenues by Source - Business-Type Activities";

        dest.NSeries.Add("C8:C14", true);

        DataLabels datalabels;
        for (int i = 0; i < dest.NSeries.Count; i++) {
            datalabels = dest.NSeries[i].DataLabels;
            datalabels.ShowCellRange = true;
            datalabels.ShowValue = true;
            if (isPieChart(dest.Type)) {
              datalabels.Position = LabelPositionType.OutsideEnd;
              datalabels.ShowLegendKey = true;
              datalabels.ShowCategoryName = true;
              datalabels.IsNeverOverlap = true; 
        dest.NSeries.CategoryData = "A8:A14";
        // adjust default chart position
        dest.ChartObject.Left = 100;  

The sheet in question:

busactrevsource (24).zip (8.2 KB)

I’m using Aspose.Cells for .NET 22.3.0.


Thanks for the sample file.

Please notice, after an initial test, I am able to reproduce the issue as you mentioned by using your sample. I found while trying to get some pie chart data labels to be spaced properly, even trying the “IsNeverOverlap” API but to no avail. I have logged a ticket with an id “CELLSNET-50780” for your issue. We will look into it soon.

Once we have an update on it, we will let you know.