We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

How to hide Data Labels?

Hi everybody,

how can I turn off data labels with SyncFusion.XlsIO in PowerPoint while working with a chart?




3 Replies

VA Vijayasurya Anandhan Syncfusion Team June 20, 2019 09:51 AM UTC

Hi Yuri,

Thank you for contacting Syncfusion support.

It is not possible to turn off data labels of the chart in the PowerPoint using Essential XlsIO (Syncfusion.XlsIO). We request you to use our Essential PowerPoint library to create or modify the charts in PowerPoint.

It is possible to achieve your requirement (Turn off data labels of the chart in PowerPoint) using our Essential PowerPoint library. Please use the below code snippet to achieve your requirement.


 
//Opens a Presentation 
IPresentation presentation = Presentation.Open(@"Chart.pptx"); 
 
//Gets the first slide 
ISlide slide = presentation.Slides[0]; 
 
//Gets the chart in slide 
IPresentationChart chart = slide.Charts[0]; 
 
//Iterate each series in the chart 
for (int i = 0; i < chart.Series.Count; i++) 
{ 
    //Get or set a value indicates whether to display a chart data label values 
    chart.Series[i].DataPoints.DefaultDataPoint.DataLabels.IsValue = false; 
} 

//Save the PowerPoint presentation 
presentation.Save("Output.pptx"); 
 

We have also created a sample to meet your requirement which can be downloaded from the below link.
https://www.syncfusion.com/downloads/support/forum/145408/ze/ChartSample1529177798.zip

To know more details about working with charts in our Essential PowerPoint library, we request to visit our UG documentation page using the below link.
https://help.syncfusion.com/file-formats/presentation/working-with-charts#editing-the-chart-data

Please let us know if you need further assistance in this.

Regards,
Vijayasurya A
 



YK Yuri Kuleshov June 20, 2019 10:15 AM UTC

Hi Vijayasurya,

thanks for such the quick response. I got the point. The only question left is: am I right that DataLabels.IsValue = true|false just does nothing in XlsIO.base? I am asking because I see the API but could never get it worked. Neither with default, not with custom value labels.

Thanks


VA Vijayasurya Anandhan Syncfusion Team June 20, 2019 11:24 AM UTC

Hi Yuri,

Thank you for your update.

We suspect that you have used custom value labels in the chart. It is also possible to remove the custom data labels from the PowerPoint using our Essential Powerpoint library.

We suggest you to use the below code snippet which removes both the default and custom data labels from the PowerPoint.


 
//Opens a Presentation 
IPresentation presentation = Presentation.Open(@"Chart.pptx"); 
 
//Gets the first slide 
ISlide slide = presentation.Slides[0]; 
 
//Gets the chart in slide 
IPresentationChart chart = slide.Charts[0]; 
 
//Iterate each series in the chart 
for (int i = 0; i < chart.Series.Count; i++) 
{ 
    //Get or set a value indicates whether to display a chart data label values 
    chart.Series[i].DataPoints.DefaultDataPoint.DataLabels.IsValue = false;

   
//Gets each DataPoint from the DataPoint collection  
   foreach(IOfficeChartDataPoint dataPoint in chart.Series[i].DataPoints) 
   { 
          //Get or set a value indicates whether to display a chart data label values 
          dataPoint.DataLabels.IsValue = false; 
   } 
} 

//Save the PowerPoint presentation 
presentation.Save("Output.pptx"); 
 

To meet your requirement, we have also created a sample which can be downloaded from the below location.
https://www.syncfusion.com/downloads/support/forum/145408/ze/ChartSample-1620425612.zip

Note:
If you need to remove the data labels of the chart in an Excel document, we request you to use the same highlighted code snippet. We suggest you to use our Essential Powerpoint library to create, edit or modify PowerPoint documents and Essential XlsIO library to create, edit or modify Excel documents. Please use our below UG documentation link to know more details about our Essential Powerpoint and Essential XlsIO library.

PowerPoint: https://help.syncfusion.com/file-formats/presentation/working-with-charts
 
Excel: https://help.syncfusion.com/file-formats/xlsio/working-with-charts


Regards,
Vijayasurya A


Loader.
Up arrow icon