This project has moved. For the latest updates, please go here.

PieChart DataLabel Format Code

Dec 6, 2014 at 12:57 PM
Edited Dec 6, 2014 at 1:01 PM
I want to apply a format code to the percentage values on chart to hide zeros
But I can't find any options for FormatCode in DataLabel or anywhere in a chart
Below code did no help either, it ads the c:numFmt but zeroes are still visible and number format is General
var xml = excelChart.ChartXml;
XmlElement xmlElement = xml.CreateElement("c", "numFmt", http://schemas.openxmlformats.org/drawingml/2006/chart");
XmlAttribute formatCode = xml.CreateAttribute("formatCode");
XmlAttribute sourceLinked = xml.CreateAttribute("sourceLinked");
sourceLinked.Value = "1";
formatCode.Value = "%0,#0;-0;";
xmlElement.Attributes.Append(formatCode);
xmlElement.Attributes.Append(sourceLinked);
xml.GetElementsByTagName("c:dLbls")[0].AppendChild(xmlElement);