Free Support Forum - aspose.com

Pareto Chart

Hi! I’m trying to create a Pareto Chart with Aspose Cells - version 20.01
The Axis Format applied was “Automatic” but I need “By Category” (the default in Excel).
I tried to set it with the following code:
chart.CategoryAxis.CategoryType = Aspose.Cells.Charts.CategoryType.CategoryScale;
chart.CategoryAxis.TickLabelSpacing = 60;
It doesn’t work.
Could you please help me?
Attached you can find the result I want in excel
prova.zip (10.2 KB)

Regards,
Federica

@licensebiwayit,
Thank you for your query.
Please share your runnable console application for our analysis. We will try it here and provide you assistance accordingly.

Here the code I use to generate the chart:

Workbook workbook = new Workbook();

int index = workbook.Worksheets.Add();
Worksheet worksheet = workbook.Worksheets[index];

worksheet.Cells[0, 0].PutValue(“Defect Case”);
worksheet.Cells[0, 1].PutValue(“Qty”);

worksheet.Cells[1 0].PutValue(“Cut not straight”);
worksheet.Cells[1, 1].PutValue(9);

worksheet.Cells[2 0].PutValue(“No defect found”);
worksheet.Cells[2, 1].PutValue(7);

worksheet.Cells[3 0].PutValue(“Product not made by FLC”);
worksheet.Cells[3, 1].PutValue(3);

worksheet.Cells[4 0].PutValue(“Sample lost”);
worksheet.Cells[4, 1].PutValue(3);

worksheet.Cells[5 0].PutValue(“Incorrect hose cut length”);
worksheet.Cells[5, 1].PutValue(3);

worksheet.Cells[6 0].PutValue(“Mechanical failure”);
worksheet.Cells[6, 1].PutValue(2);

worksheet.Cells[7 0].PutValue(“Missing quantity”);
worksheet.Cells[7, 1].PutValue(1);

worksheet.Cells[8 0].PutValue(“Accessories”);
worksheet.Cells[8, 1].PutValue(1);

int chartIndex = worksheet.Charts.Add(Aspose.Cells.Charts.ChartType.ParetoLine, 5, 0, 40, 19);
string dataArea = “B2:B9”;
string categoryArea = “A2:A9”;

Aspose.Cells.Charts.Chart chart = worksheet.Charts[chartIndex];
chart.NSeries.Add(dataArea, true);
chart.PlotArea.BackgroundMode = Aspose.Cells.Charts.BackgroundMode.Transparent;
chart.PlotArea.Area.ForegroundColor = Color.Transparent;
chart.ChartArea.Area.ForegroundColor = Color.FromArgb(242, 242, 242);
chart.ChartArea.BackgroundMode = Aspose.Cells.Charts.BackgroundMode.Automatic;
chart.ChartArea.Font.Color = blueDark;

chart.CategoryAxis.CategoryType = Aspose.Cells.Charts.CategoryType.CategoryScale;
chart.CategoryAxis.TickLabelSpacing = 60;

chart.NSeries.CategoryData = categoryArea;
chart.NSeries[0].Name = “=B1”;

chart.ShowLegend = false;

workbook.Save(@“C:\prova.xlsx”, SaveFormat.Xlsx);

@licensebiwayit,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-47169 – CategoryType.CategoryScale not set in ParetoLine chart

@licensebiwayit,
This is to inform you that we have fixed your issue (logged earlier as “CELLSNET-47169”) now. We will soon provide you the fixed version after performing QA and incorporating other enhancements and fixes.

Thank you very much. Really appreciated.
Federica

The issues you have found earlier (filed as CELLSNET-47169) have been fixed in Aspose.Cells for .NET v20.2. This message was posted using Bugs notification tool by Amjad_Sahi

Dear sir,
thank you very much.
I tested the new version and now the CategoryScale is set correclty.

Unfortunately I found another problem on Pareto Chart.
The excel is created correctly but when I try to save the chart as image the line disappears and also the name of the serie disappears from graph (excluded for the first bar).
Attached you can find the excel created and the image.
The code used is the same of previous post, with added at the end the following lines:

Aspose.Cells.Rendering.ImageOrPrintOptions imgOptions = new Aspose.Cells.Rendering.ImageOrPrintOptions();
imgOptions.ImageType = Aspose.Cells.Drawing.ImageType.Png;
imgOptions.HorizontalResolution = 300;
imgOptions.VerticalResolution = 300;
chart.ToImage(@“c:\prova.png”, imgOptions);

Prova2.zip (40.0 KB)

@licensebiwayit,
We were able to observe the issue but we need to look into it more. We have logged the issue in our database for investigation and for a fix. Once, we will have some news for you, we will update you in this topic.

This issue has been logged as

CELLSNET-47177 – ParetoLine chart series name and line not rendered to image