Radar charts - Aspose.Cells.Charts.PlotEmptyCellsType.NotPlotted

chart.PlotEmptyCellsType = Aspose.Cells.Charts.PlotEmptyCellsType.NotPlotted does not work with Radar charts in Aspose.Cells. Is there any chance this could be fixed?

@alainronet,

Which version of the product you are using? Please try our latest version/fix: Aspose.Cells for .NET v18.5.4:

I have tested your scenario/case using the following sample code with v18.5.4 and the output file is fine tuned. The generated chart has the relevant option set (for “PlotEmptyCellsType.NotPlotted”):
e.g
Sample code:

var wBook = new Workbook();
            var sheet = wBook.Worksheets[0];
            sheet.Name = "Source Image";

            PrepareData(sheet);

            var chartIndex = sheet.Charts.AddFloatingChart(ChartType.Radar, 3, 30, 800, 400);
            var chart = sheet.Charts[chartIndex];

            chart.CategoryAxis.MajorTickMark = TickMarkType.Outside;
            chart.CategoryAxis.MinorTickMark = TickMarkType.None;
            chart.CategoryAxis.AxisBetweenCategories = false;
            //hiden empty cell
            chart.PlotEmptyCellsType = PlotEmptyCellsType.NotPlotted;
            chart.PlotVisibleCells = true;

            chart.NSeries.Add("B2:AZ2", false);
            chart.NSeries.CategoryData = "A2:A2";

            var sheet1 = wBook.Worksheets.Add("Export Image");
            wBook.Save("e:\\test2\\out1.xlsx");

.....

private void PrepareData(Worksheet sheet)
        {
            var rm = new Random();

            //prepare data source
            sheet.Cells[0, 0].PutValue(string.Empty);
            for (int i = 0; i <= 50; i++)
            {
                sheet.Cells[0, i + 1].PutValue(DateTime.Now.AddDays(i));
            }
            sheet.Cells[1, 0].PutValue("Serise 1");
            for (int i = 1; i <= 50; i++)
            {
                var sq = rm.Next(1, 100);
                sheet.Cells[1, i].PutValue(i + sq * 0.1);
            }
            //set empty cell value
            sheet.Cells[1, 8].PutValue(string.Empty);
            sheet.Cells[1, 22].PutValue(string.Empty);
            sheet.Cells[1, 40].PutValue(string.Empty);
        }

I have attached the output file for your reference. Also, see the screenshot of the chart’s image having relevant option set.

file1.zip (9.0 KB)

Hi, sorry, I should have clarified. When you use the ToImage() method on the chart class after creating a radar chart, the returned image does not look as it appears in Excel. The property mentioned is not honoured.

@alainronet,

Which version of the product you are using? When I add a line to the above code segment, I got an exception:
“Index was out of range. Must be non-negative and less than the size of the collection”:
chart.ToImage("e:\\test2\\out1.png", ImageFormat.Png);

If you are using different code and template file, kindly do share us to reproduce the issue (“image does not look as it appears in Excel”), we will check it soon.

Hi Amjad, we are using v 17.2. Here is the code we are using:

Aspose.Cells.Workbook workbook = new Workbook();
Aspose.Cells.Worksheet worksheet = workbook.Worksheets.Add(“test”);
int index = workbook.Worksheets[“test”].Charts.Add(ChartType.Pyramid, 0, 0, 40, 16);
Chart chart = workbook.Worksheets[“test”].Charts[index];

        worksheet.Cells["A1"].PutValue(50);
        worksheet.Cells["A2"].PutValue(100);
        worksheet.Cells["A3"].PutValue(150);
        worksheet.Cells["B1"].PutValue(4);
        worksheet.Cells["B2"].PutValue(20);
        worksheet.Cells["B3"].PutValue(50);

        chart.NSeries.Add("A1:B3", true);

        var newChartImage = chart.ToImage();

        Document doc = new Document();
        Aspose.Words.DocumentBuilder builder = new DocumentBuilder(doc);
        builder.InsertImage(newChartImage);
        doc.Save(@"c:\temp\testExcelChart.docx", SaveFormat.Docx);

@alainronet,

Is this original code for the issue. I could not find the lines regarding plotting empty cells, i…,

chart.PlotEmptyCellsType = PlotEmptyCellsType.NotPlotted;
chart.PlotVisibleCells = true;

Also, you are using Pyramid chart and not Radar chart. I tried the following sample code using v18.5.4 and it works fine. Both chart image and Excel file’s chart are identical.
e.g
Sample code:

 Aspose.Cells.Workbook workbook = new Workbook();
            Aspose.Cells.Worksheet worksheet = workbook.Worksheets.Add("test");
            int index = workbook.Worksheets["test"].Charts.Add(ChartType.Pyramid, 0, 0, 40, 16);
            Chart chart = workbook.Worksheets["test"].Charts[index];

                      
            worksheet.Cells["A1"].PutValue(50);
            worksheet.Cells["A2"].PutValue(100);
            worksheet.Cells["A3"].PutValue(150);
            worksheet.Cells["B1"].PutValue(4);
            worksheet.Cells["B2"].PutValue(20);
            worksheet.Cells["B3"].PutValue(50);

            chart.NSeries.Add("A1:B3", true);

            chart.PlotEmptyCellsType = PlotEmptyCellsType.NotPlotted;
            chart.PlotVisibleCells = true;

            var newChartImage = chart.ToImage();

            newChartImage.Save("e:\\test2\\out1.png", ImageFormat.Png);

            workbook.Save("e:\\test2\\out1.xlsx");

Sorry, Amjad, I gave you the wrong code. That was my proof of concept fro grabbing the image object. Do you have any code you can use for a radar chart and then do everything else the same. If not, I can get the code from my colleague.

Thanks

@alainronet,

Kindly get the code and provide us here to reproduce the issue, we will check and log appropriate ticket(s) for the issue.