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

Free Support Forum - aspose.com

Problem with pie of pie chart to image

Hi:
I use “Chart.ToImage()” to export images. All data labels are the same.
Pieofpie.png (48.6 KB)

@Beyond5566,

Thanks for the screenshot and details of the issue.

Please zip your template Excel file (containing the chart) and attach it, we will check it soon.

@Amjad_Sahi
This is my template Excel.
Pieofpie.zip (9.8 KB)

@Beyond5566,

Thanks for the template file.

After an initial test, I am able to reproduce an issue by using the following sample code with your template file. I found data labels on Pie of Pie chart are not rendered correctly in the output PDF. I used the latest version (20.4) of Aspose.Cells for .NET:
e.g
Sample code:

Workbook workbook = new Workbook("e:\\test2\\Pieofpie.xlsx");

            Worksheet sheet = workbook.Worksheets[0];
            Chart chart = sheet.Charts[0];
            chart.ToPdf("e:\\test2\\out1.pdf");

I have logged a ticket with an id “CELLSNET-47334” for the issue. We will look into it soon.

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

@Beyond5566,

I just found you are rendering the chart to image and not PDF, so I evaluated your issue further using our latest version/fix (Aspose.Cells for .NET v20.4.4) and following sample code, it works fine and as expected:
e.g
Sample code:

 Workbook workbook = new Workbook("e:\\test2\\Pieofpie.xlsx");
            Worksheet sheet = workbook.Worksheets[0];
            Chart chart = sheet.Charts[0];
            chart.ToImage("e:\\test2\\out12.png", ImageFormat.Png);

The output image file is Ok and similar to input chart in the Excel file. Please try using Aspose.Cells for .NET v20.4.4 and let us know your feedback:
Aspose.Cells20.4.4 For .Net2_AuthenticodeSigned.Zip (5.4 MB)
Aspose.Cells20.4.4 For .Net4.0.Zip (5.4 MB)
Aspose.Cells20.4.4 For .NetStandard20.Zip (5.3 MB)

@Amjad_Sahi,
I’ve found this problem with rendering images directly after drawing pieofpie chart using table data.
Sample code:
Workbook workbook = new Workbook(“e:\Pieofpie.xlsx”);
Worksheet worksheet = workbook.Worksheets[0];
int chartIndex = worksheet.Charts.Add(ChartType.PiePie, 0, 5, 15,15);
Chart chart = worksheet.Charts[chartIndex];
var chartRange = $"{CellsHelper.CellIndexToName(1, 2)}:{CellsHelper.CellIndexToName(4, 2)}";
chart.NSeries.Add(chartRange, true);
chart.NSeries.CategoryData = $"{CellsHelper.CellIndexToName(1, 1)}:{CellsHelper.CellIndexToName(4, 1)}";
chart.ShowLegend = false;
var series = chart.NSeries[0];
series.SplitType = ChartSplitType.Position;
series.SplitValue = 3;
series.DataLabels.LinkedSource = $"=Sheet2!$D$2:$D$6";
series.DataLabels.ShowCellRange = true;
series.DataLabels.Position = LabelPositionType.BestFit;
series.HasLeaderLines = false;
chart.ToImage(“e:\output.png”,ImageFormat.Png);
Pieofpie.zip (6.6 KB)

@Beyond5566,

Thanks for the template file.

Please notice, I am able to reproduce your issue by using your sample code with your template file. I found data labels on Pie of Pie chart are not rendered correctly in the output image. I used the latest version (20.4) of Aspose.Cells for .NET:

I have logged a ticket with an id “CELLSNET-47336” for the issue. We will look into it soon.

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

A post was split to a new topic: Problem with scatter chart to image

@Amjad_Sahi
Has this issue been solved?

@Beyond5566,
Please spare us a little more time for complete evaluation and investigation for your issues. If it is not much complex, you should be receiving the fix before the end of next week or even before it. If the issue is complex, it might take a couple of weeks.

@Beyond5566,

Just to inform you that we are scheduled to publish our next official release, i.e., Aspose.Cells for .NET v20.6 in the next week. The new release includes the enhancement we made for your issue “CELLSNET-47334” (although the issue not fixed completely). We recommend you kindly give it a try to the latest version (once it will be released publicly)

@Beyond5566,

We have made some improvements for your issues in Aspose.Cells for .NET v20.6. You may also get the version @ NuGet repos. here (https://www.nuget.org/packages/Aspose.Cells/20.6.0).