How to give custom number format for the data points and Value Axis of a chart?

Hi there,


I want to set the values in percentage and number(thousands separator) for the axis values and data points up to 1 precision after decimal point.
using the below code , I am able to set the values in percentage and number(thousands separator) for the axis values and data points but up to 2 precision after decimal point.

So I want to assign some custom format to achieve the same up to 1 precision after decimal point.

Code:

chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 0, chartSeries.SeriesTitle), ac.ChartType.ClusteredColumn);

IChartSeries series = chart.ChartData.Series[seriesNo];
foreach (ac.IChartDataPoint dp in series.DataPoints)
{
IDataLabel dataLabel = dp.Label;
dataLabel.DataLabelFormat.ShowValue = true;

if (seriesDataType.Contains(“number”))
{
dp.Value.AsCell.PresetNumberFormat = 4;
} }
else if (seriesDataType.Contains(“percent”))
{
dp.Value.AsCell.PresetNumberFormat = 10; // 0.00%
}
}

How can we give custom number format instead of “PresetNumberFormat”? Please help.

Thanks in advance.

Hi Pardeep,

I have observed your requirements and like to share that you can set the custom format for chart data as well You can use the following sample code on your end. You can set the format string by generating the equivalent string in PowerPoint first and then setting the same for CustomNumberFormat.

cell.Value.AsCell.CustomNumberFormat = = “0.00000”;

I hope this will be helpful. Please share, if I may help you further in this regard.

Many Thanks,