Unable to Refresh Chart with New Data Using Aspose.Slides for .NET

@padair,

I have worked with the sample code and source file shared by you and i have been able to reproduce the specified issue. A ticket with ID SLIDESNET-40401 has been logged in our issue tracking system to further investigate and resolve the issue.This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

The issues you have found earlier (filed as SLIDESNET-40401) have been fixed in this update.

Hi, I’m facing same issue with the Aspose.Slides version we are currently using (20.9) and also with the latest version (21.7). Chart is not getting refreshed until we click “Edit Data”.

Here is the test code to replicate the issue

public void AutoRefreshChart()
    {
        int defaultWorksheetIndex = 0;
        Presentation presentation = new Presentation();
        ISlide sld = presentation.Slides[0];

        //clone chart
        Presentation srcPres = new Presentation(@".\Templates\ShapeMaster.pptx");
        IShape _tmpMstrChart = srcPres.Slides[0].Shapes[0];

        IShape cloneShape = sld.Shapes.AddClone(_tmpMstrChart, 50, 50, 500, 300);

        IChart chart = (Chart)cloneShape;
        IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

        //clear sample data in workbook
        chart.ChartData.ChartDataWorkbook.Clear(defaultWorksheetIndex);
        chart.ChartData.Categories.Clear();

        //add categories
        chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 1, 0, "A1234"));
        chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 2, 0, null));
        chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 3, 0, null));
        chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, 4, 0, "STANDARD"));

        //add series data
        IChartSeries series;
        series = chart.ChartData.Series.First(x => x.Name.ToString() == "Name");
        series.DataPoints.Clear();
        chart.ChartData.ChartDataWorkbook.GetCell(defaultWorksheetIndex, 0, 0).Value = "Name";
        series.Name.SetFromOneCell(fact.GetCell(defaultWorksheetIndex, 0, 0));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 1, 0, "A1234"), fact.GetCell(defaultWorksheetIndex, 1, 1, null));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 0, " "), fact.GetCell(defaultWorksheetIndex, 2, 1, float.Parse("0.0064")));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 0, " "), fact.GetCell(defaultWorksheetIndex, 3, 1, float.Parse("0.0080")));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 4, 0, "STANDARD"), fact.GetCell(defaultWorksheetIndex, 4, 1, null));

        series = chart.ChartData.Series.First(x => x.Name.ToString() == "ITEMCODE");
        series.DataPoints.Clear();
        chart.ChartData.ChartDataWorkbook.GetCell(defaultWorksheetIndex, 0, 2).Value = "A1234";
        series.Name.SetFromOneCell(fact.GetCell(defaultWorksheetIndex, 0, 2));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 1, 2, float.Parse("0.0050")));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 2, 2, null));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 3, 2, null));
        series.DataPoints.AddDataPointForBarSeries(fact.GetCell(defaultWorksheetIndex, 4, 2, null));

        series = chart.ChartData.Series.First(x => x.Name.ToString() == "STANDARD");
        series.DataPoints.Clear();
        chart.ChartData.ChartDataWorkbook.GetCell(defaultWorksheetIndex, 0, 3).Value = "STANDARD";
        series.Name.SetFromOneCell(fact.GetCell(defaultWorksheetIndex, 0, 3));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 1, 3, null), fact.GetCell(defaultWorksheetIndex, 1, 4, null));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 2, 3, null), fact.GetCell(defaultWorksheetIndex, 2, 4, null));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 3, 3, null), fact.GetCell(defaultWorksheetIndex, 3, 4, null));
        series.DataPoints.AddDataPointForScatterSeries(fact.GetCell(defaultWorksheetIndex, 4, 3, "STANDARD"), fact.GetCell(defaultWorksheetIndex, 4, 4, float.Parse("0.0114")));

        chart.DisplayBlanksAs = DisplayBlanksAsType.Gap;
        chart.Axes.VerticalAxis.NumberFormat = "0.00%";

        //var formula = chart.ChartData.GetRange(); //$"Sheet1!$A$1:$E$5";
        //chart.ChartData.SetRange(formula);

        //save
        presentation.Save(@"C:\\Temp\\autorefreshTest1.pptx", Aspose.Slides.Export.SaveFormat.Pptx);

    }

Attached is the template used to clone the chart fromShapeMaster.zip (38.0 KB)

@agollamandala,
Thank you for the issue description. I will answer you as soon as possible.

1 Like

@agollamandala,
I reproduced the problem for updating the cloned chart on my side and logged the issue with ID SLIDESNET-42737 in our tracking system. Our development team will investigate this case. You will be notified when the issue is resolved.

Thanks for the quick response, @Andrey_Potapov!

Just to give you more details on the issue, the issue was happening with the series (NAME_BAR and STND_BAR in the attached template) that are pointing (or referencing) to data cells of a different series.

We are able to find a work around to the issue by giving the series its own data (instead of pointing to other series data cells) . it required us to duplicate the data, but it fixed the issue for us.

@agollamandala,
I am glad you found the workaround yourself. We will do our best to resolve this issue.

1 Like

Hi there. I got the same problems with version 20.10…
Chart is not refreshed until the datasource is edited in PPT. SetRange is not an option as layout is destroyed…
:frowning:

@MOlinger,
Thank you for contacting support. There were many updates after version 20.10. Please check your problem using the latest version of Aspose.Slides. If the issue persists, please create a new topic and share the presentation file and code example reproducing the problem.

The issues you have found earlier (filed as SLIDESNET-42737) have been fixed in this update.