Getting error after adding data labels from values

Hi 

I am getting the following error after trying to add Data label from values. 

Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.serializeDataLabelRangeCache(XmlWriter writer, Dictionary`2 values)
   at Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.SeriealizeValuesFromCellsRange(XmlWriter writer, ChartSerieImpl series)
   at Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.SerializeScatterSeries(XmlWriter writer, ChartSerieImpl series)
   at Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.SerializeChartSeries(XmlWriter writer, ChartImpl chart, ChartSerieImpl firstSeries, SerializeSeriesDelegate serializator)
   at Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.SerializeScatterChart(XmlWriter writer, ChartImpl chart, ChartSerieImpl firstSeries)
   at Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.SerializeMainChartTypeTag(XmlWriter writer, ChartImpl chart, Int32 groupIndex)
   at Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.SerializePlotArea(XmlWriter writer, ChartImpl chart, RelationCollection relations)
   at Syncfusion.OfficeChart.Implementation.XmlSerialization.Charts.ChartSerializator.SerializeChart(XmlWriter writer, ChartImpl chart, String chartItemName)
   at Syncfusion.Presentation.FileDataHolder.WriteChart(PresentationChart chart)
   at Syncfusion.Presentation.DrawingSerializator.SerializeGraphicFrame(XmlWriter xmlWriter, Shape shape)
   at Syncfusion.Presentation.DrawingSerializator.SerializeShapes(XmlWriter xmlWriter, BaseSlide slide)
   at Syncfusion.Presentation.DrawingSerializator.SerializeShapeTree(XmlWriter xmlWriter, BaseSlide slide)
   at Syncfusion.Presentation.Serializator.SerializeCommonSlide(XmlWriter xmlWriter, BaseSlide slide)
   at Syncfusion.Presentation.Serializator.SerializeSlide(XmlWriter xmlWriter, Slide slide)
   at Syncfusion.Presentation.FileDataHolder.WriteSlides()
   at Syncfusion.Presentation.FileDataHolder.Write()
   at Syncfusion.Presentation.FileDataHolder.WriteDocument(Stream stream)
   at Syncfusion.Presentation.Presentation.SaveFromStream(Stream stream)
   at Syncfusion.Presentation.Presentation.SaveAsStream(Stream fileStream)
   at Syncfusion.Presentation.Presentation.Save(Stream stream)
   at Revuze.Pro.Reports.Services.ReportsService.GenerateSwotPPT(SwotDataModel swotModel) in C:\Users\moran\source\repos\Pro\Revuze.Pro.Reports\Revuze.Pro.Reports\Services\ReportsService.cs:line 137

I want to add data to replace the x and y values and the column1 value. 



Attachment: Swot_template_47235bd7.zip

6 Replies 1 reply marked as answer

LB Lokesh Baskar Syncfusion Team January 19, 2022 02:33 PM UTC

Could you please try the same application at your end and provide us confirmation whether you are facing issue in this simple sample too. 
If the issue not reproduced using the above sample application at your end, then could you please modify the above sample as issue reproduceable sample application and share us. Thereby, we will proceed further to replicate the same problem at our end and will provide the more details.

Regards,
Lokesh B
 



MM Moran Monovich January 31, 2022 02:59 PM UTC

Thank you.

The issue was with the data, once I limit the value of the bullets to 2 decimal points after the dot, I stopped getting the error message. 


But for some reason, I can't see the custom data labels after I create the file even in the example you sent me.

value from cells



LB Lokesh Baskar Syncfusion Team February 1, 2022 04:36 PM UTC

Hi Moran,

 
Regarding I can't see the custom data labels after I create the file even in the example you sent me.
To display the chart data label values and category name for the data label, then we suggest you to set true for DataLabels.IsValue, and DataLabels.IsCategoryName. Please refer to the below highlighted code snippet.  
FileStream Stream = new FileStream(@"Swot template.pptx", FileMode.Open); 
IPresentation pptxDoc = Presentation.Open(Stream); 
Stream.Close(); 
//Retrieves the slide instance. 
ISlide slide = pptxDoc.Slides[3]; 
//Gets the chart in slide 
IPresentationChart chart = slide.Shapes[41] as IPresentationChart; 
chart.ChartData.SetValue(2, 1, 0.2); 
chart.ChartData.SetValue(2, 2, 0.3); 
chart.ChartData.SetValue(2, 3, "Testvalue1"); 
chart.ChartData.SetValue(3, 1, 0.4); 
chart.ChartData.SetValue(3, 2, 0.5); 
chart.ChartData.SetValue(3, 3, "Testvalue2"); 
chart.ChartData.SetValue(4, 1, 0.6); 
chart.ChartData.SetValue(4, 2, 0.7); 
chart.ChartData.SetValue(4, 3, "Testvalue3"); 
 
IOfficeChartSerie serie = chart.Series[0]; 
serie.DataPoints.DefaultDataPoint.DataLabels.IsValue = true; 
serie.DataPoints.DefaultDataPoint.DataLabels.IsCategoryName = true; 
 
Stream = new FileStream(@"Swot template_output.pptx", FileMode.Create); 
//Save and close the presentation 
pptxDoc.Save(Stream); 
Stream.Close(); 
pptxDoc.Close(); 



MM Moran Monovich February 8, 2022 05:47 PM UTC

Hi

This is not working for me, I need the data from a specific column. My issue is that I can't see the values as data labels. I only see them after I 

  1. Click on one of the data labels
  2. Right-click - format data labels 
  3. Select "select range" near "Value from cells"
This is my code
var dataLabels = chart.Series[0].DataPoints.DefaultDataPoint.DataLabels;
dataLabels.ValueFromCellsRange =
chart.ChartData[ _startRowIndex, 3,bulletGraphData.Count + 1, 3];
dataLabels.Position = OfficeDataLabelPosition.Above;
dataLabels.ShowLeaderLines = false;
dataLabels.IsValueFromCells = true;
chart.Refresh();

I attached the ppt file I have created so you can reproduce the issue


Attachment: SwotAnalysis_February_2022_(2)_1166057f.zip


LB Lokesh Baskar Syncfusion Team February 9, 2022 02:48 PM UTC

Hi Moran, 

We have tried to reproduce the reported issue using the given code snippet but, it works properly at our end. For your reference, we have attached the sample application which we used to reproduce the reported issue and it can be downloaded from the below link:  
https://www.syncfusion.com/downloads/support/directtrac/general/ze/PresentationConsoleSample-53915408.zip

Please refer to the screenshot of the output PPTX document which generated at our end from the below link: Here the data label value shows properly.
 


Could you please try the same sample application at your end and provide us confirmation whether you are facing issue in this sample too. 
 
If the issue not reproduced using the above sample application at your end, then could you please modify the above sample as issue reproducible sample application, Syncfusion product version which you are using in your application and share us. Thereby, we will proceed further to replicate the same problem at our end and will provide the more details. 


Regards,
 
Lokesh B 


Marked as answer

MM Moran Monovich February 14, 2022 10:49 AM UTC

Hi

The issue has been resolved. 

Once I replaced the line of code:

IPresentation pptxDoc = Presentation.Open(new FileStream(_generalTempaltePath, FileMode.Open)).Clone();

With yours:

FileStream Stream = new FileStream(_swotTemplate, FileMode.Open);
IPresentation pptxDoc = Presentation.Open(Stream);
Stream.Close();

Loader.
Up arrow icon