Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Thu May 05, 2022 12:10 pm

When I want to edit a donut chart data I get the following error. Spire presentation version is 7.4.5

01.png


I realized that the following line cause the problem. Can you check it?

Code: Select all
chart.ChartData.Clear(0, 0, categoryCount + 1, seriesCount + 1);



Template File:
template.zip


Source code:

Code: Select all
using Spire.Presentation;
using System.Linq;
using Spire.Presentation.Charts;
using System;
using System.Collections.Generic;

namespace PptxTesterPaidVersion
{
    class Program
    {
        static void Main(string[] args)
        {
            PieChartEditDataCrashing();
        }

        private static void PieChartEditDataCrashing()
        {
            //Load template presentation
            Presentation templatePresentation = new Presentation();
            templatePresentation.LoadFromFile("template.pptx");

            //Create New Presentation
            Spire.Presentation.Presentation presentation = new Spire.Presentation.Presentation();
            presentation.Slides.RemoveAt(0);

            //Get slide from template presentation. index:1
            ISlide cloneSlide = templatePresentation.Slides.ToArray().ElementAtOrDefault(0);

            //---
            //Get Chart                       
            //IChart chart = templateSlide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Content Placeholder 15") as IChart;
            IChart chart = cloneSlide.Shapes.ToArray().FirstOrDefault(x => x.Name == "Chart 14") as IChart;

            int seriesCount = 1;
            int categoryCount = 2;

            chart.ChartData.Clear(0, 0, categoryCount + 1, seriesCount + 1);

            chart.ChartData[1, 0].Text = "Read a printed newspaper";
            chart.ChartData[2, 0].Text = "Read a digital magazine";

            chart.ChartData[0, 1].Text = "Total";

            chart.ChartData[1, 1].NumberValue = 0.4315;
            chart.ChartData[2, 1].NumberValue = 0.053899999999999997;


            var startIndexAddSeries = chart.Series.Count + 1;
            for (int i = startIndexAddSeries; i <= seriesCount; i++)
            {
                chart.Series.Append(chart.ChartData[0, i]);
            }
            if (chart.Series.Count > seriesCount)
            {
                for (int i = chart.Series.Count - 1; i >= seriesCount; i--)
                {
                    chart.Series.RemoveAt(i);
                }
            }
            chart.Categories.CategoryLabels = chart.ChartData["A2", "A" + (categoryCount + 1)];
            for (int i = 0; i < seriesCount; i++)
            {
                string letter = GetColumnName(i + 1);
                chart.Series[i].Values = chart.ChartData[letter + "2", letter + (categoryCount + 1)];
            }

            presentation.Slides.Append(cloneSlide);

            //Save and launch to view the PPTX document.
            presentation.SaveToFile("PieChartEditDataCrashing_01.pptx", Spire.Presentation.FileFormat.Pptx2010);
        }

        public static string GetColumnName(int index)
        {
            const string letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

            var value = "";

            if (index >= letters.Length)
                value += letters[index / letters.Length - 1];

            value += letters[index % letters.Length];

            return value;
        }
    }
}

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Fri May 06, 2022 9:14 am

Hello,

Thanks for your feedback.

I have reproduced the issue you mentioned and logged it in our bug tracking system with the ticket SPIREPPT-1939. If there is any progress I will notify you in time. Sorry for the inconvenience caused.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Wed May 11, 2022 3:50 pm

Any updates on this?

majeed_s
 
Posts: 80
Joined: Thu Mar 25, 2021 4:13 pm

Fri May 13, 2022 3:43 am

Hi,

This issue has been fixed and is now entering the test phase. I will keep you informed of new update.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Mon May 23, 2022 10:07 am

Any updates on this?

majeed_s
 
Posts: 80
Joined: Thu Mar 25, 2021 4:13 pm

Wed May 25, 2022 1:12 am

Hello,

Sorry for the delay.
The fix has passed the test and we will release a new version within this month. I will notify you at that time.
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Fri May 27, 2022 10:35 am

Hi,

Thanks for your patience!

Glad to inform you that we just released Spire.Presentation Pack(Hot Fix) Version:7.5.3 which fixes your issue SPIREPPT-1939.

Please download the fix version from the following links to test.
Website link:
https://www.e-iceblue.com/Download/down ... t-now.html
Nuget link:
https://www.nuget.org/packages/Spire.Presentation/7.5.3
Sincerely,
Andy
E-iceblue support team
User avatar

Andy.Zhou
 
Posts: 483
Joined: Mon Mar 29, 2021 3:03 am

Thu Jun 02, 2022 2:03 pm

Thank you. Spire.Presentation Pack(Hot Fix) Version:7.5.3 fixed the problem.

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Thu Jun 02, 2022 11:53 pm

Hello Omur,

Glad to hear that! If you encounter any issues related to our products in the future, just feel free to contact us.
Wish you all the best!

Sincerely,
Lisa
E-iceblue support team
User avatar

Lisa.Li
 
Posts: 1271
Joined: Wed Apr 25, 2018 3:20 am

Return to Spire.Presentation