Presentation series labels not refreshing

Hi - I have a PPT file with a chart such as the below and I'm trying to dynamically replace the data, however when I do so, the some of the chart labels get completely messed up (see second picture)

My code is really simple:

              Dim chtData()() As Object = GetRangeArray(rng, oCht.ChartData.ChartDataSeriesInRows)

              cht.ChartData().SetChartData(chtData)

              'cht.PrimaryCategoryAxis.CategoryLabels = cht.ChartData(2, 1, chtData.Length, 1)

              With cht.Series(0)

                  .CategoryLabels = cht.ChartData(2, 1, chtData.Length, 1)

                  .Values = cht.ChartData(2, 2, chtData.Length, 2)

              End With

 Image_6676_1702662742651

It appears the Syncfusion is not updating the labels, except for one, very randomly, is working

Image_6887_1702662900144

Here's the data according to Powerpoint (looks good to me)

Image_7015_1702663124288

If I go into powerpoint, I can "Reset Label Text" and everything looks good. So my guess is Syncfusion is just not updating the labels. Is there any way to do this?


5 Replies

SB Sneha Biju Syncfusion Team December 18, 2023 01:18 PM UTC

Hi Aaron,

On further analyzing the given details, we have tried to create a sample to replace the chart data of the existing chart in the Presentation file and it is working fine. We have attached the sample along with the input and output presentation file.

If you are still facing the same issue, please share the modified sample and input document with us so that we can reproduce the exact problem and provide you with an appropriate solution at the earliest.

Regards,
Sneha.


Attachment: Replacechartdata_b915bd8e.zip


AA Aaron December 18, 2023 08:50 PM UTC

I did some more digging at it appears that making the same "Reset Label Text" in my template fixed the issue.

Now I am facing another issue with the layout of the labels where the label position is random and really ugly

Here is my template:

Image_9212_1702932455625

And here is after I stuff data into the table:

Image_1677_1702932482926

You'll see has a lot of overlapping labels and some labels that are not even corresponding to the regions they label. I cannot find any options in the API to get the layout, to be "automatic outside" the circle for example. Is there any way to get labels to lay out better after setting data? Thanks.



AA Akash Arul Syncfusion Team December 19, 2023 04:30 PM UTC

Aaron, we found that your requirement is to set the data label position. You can set the data label position using DataLabel.Position API. Please find the code snippet to set the position below.
Code snippet:

//Set the data label position.

cht.Series[0].DataPoints.DefaultDataPoint.DataLabels.Position = OfficeDataLabelPosition.Automatic;

By following this approach, we have encountered an issue “Corruption issue while setting position for data label in Presentation”. We will validate this issue and update you with more details by the end of this week.



AA Aaron December 19, 2023 05:30 PM UTC

Awaiting your response - I tried that but yes, it corrupted the PPT file. Thank you!



AA Akash Arul Syncfusion Team replied to Akash Arul December 22, 2023 02:43 PM UTC

Aaron, sorry for the miscommunication. The code snippet that we shared in our last update using DataLabel.Position API, cannot be done. Because in Microsoft PowerPoint application, the DataLabel.Position API is not available for this chart type (Doughnut chart). This is the reason the document is corrupted.

To achieve your requirement (setting the data label in the required position), you can use the Left and Top API. We have prepared a sample for your requirement and attached it here. Please take a look at it.

Refer to the below UG documentation to know more about replacing and resizing the chart elements.
https://help.syncfusion.com/file-formats/xlsio/working-with-charts#resizing-chart-elements


Attachment: VB_base_501bc4c0.zip

Loader.
Up arrow icon