We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Percentage Column Stacked Chart


I am creating one PercentageColumnStacked chart.

In the chart i can enable showValues in data labels. And In PPT i can manualy modify some specific the DataLables values to my desired values.

How can i do the same using Aspose Slides API's. I am attaching sample PPT and screenshot.

Can you please share some code sample with me.



Hi Amit,

I have observed the requirements shared and suggest you to please try using following sample code on your end to serve the purpose.

DataLabelEx label = new DataLabelEx(series);
label.ShowValue = true;
label.NumberFormat = “0.0%”;
label.LinkedSource = false;


Please share, if I may help you further in this regard.

Many Thanks,


Thanks for your reply. But the code which you provided is not working logically for me.

I dont want to apply Number format as '%'. As if you observer it for percentage stacked column when we apply the Number format it actually converts the absolute value to percentage value. But in actual the percentage value for the data point will be different than that value.

Please refer the attachment. I can apply custom text as well in data labels. I can put any value which i wants.

Please let me know how can i do that.



Hi Amit,

I have observed the requirements shared and like to share that there is no automated way available in Aspose.Slides and even in PowerPoint to auto calculate the series data point values for particular categories and then displaying the percentage as labels. You need to calculate this on your end and then add custom labels to serve the purpose. I have created a sample code for your convenience in this regard to serve the purpose.

public static void testLabels()
PresentationEx pres = new PresentationEx();
SlideEx slide = pres.Slides[0];

ChartEx chart = slide.Shapes.AddChart(ChartTypeEx.StackedColumn, 20, 20, 400, 400);
ChartSeriesEx series = chart.ChartData.Series[0];
ChartCategoryEx cat;
double total_value = 0.0f;

double[] total_for_Cat=new double [chart.ChartData.Categories.Count];
for (int k = 0; k < chart.ChartData.Categories.Count; k++)
cat = chart.ChartData.Categories[k];

for (int i = 0; i < chart.ChartData.Series.Count; i++)
total_for_Cat[k] = total_for_Cat[k] + (double)(chart.ChartData.Series[i].Values[k].Value);

double dataPontPercent = 0f;

for (int x = 0; x < chart.ChartData.Series.Count; x++)
series = chart.ChartData.Series[x];
series.Labels.ShowLegendKey = false;

for (int j = 0; j < series.Values.Count; j++)
DataLabelEx label = new DataLabelEx(series);
label.Id = j;
// label.ShowValue = true;
dataPontPercent = ((double)series.Values[j].Value / total_for_Cat[j]) * 100;

PortionEx port = new PortionEx();
// port.Text = dataPontPercent.ToString() + " %";

port.Text = String.Format("{0:F2} %", dataPontPercent);
port.PortionFormat.FontHeight = 8f;
label.TextFrame.Paragraphs.Add(new ParagraphEx());
label.ShowSeriesName = false;
label.ShowPercentage = false;
label.ShowLegendKey = false;
label.ShowCategoryName = false;
label.ShowBubbleSize = false;



// Save presentation with chart
pres.Write(@“D:\Aspose Data\AsposeChart.pptx”);

There is minor issue in custom labels that it is showing the series legend key. I have created an issue with ID SLIDESNET-34525 to further investigate and resolve this issue.

Many Thanks,

The issues you have found earlier (filed as SLIDESNET-34525) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

Presentation presentation = new Presentation(source + “MyPPTAspose.pptx”);
//ISlideCollection slidescollection = presentation.Slides;

//Accessing the first slide
ISlide slide = presentation.Slides[0];

IChart chart = slide.Shapes.AddChart(ChartType.StackedColumn, 100, 100, 400, 400);
// Getting the chart data worksheet
IChartDataWorkbook fact = chart.ChartData.ChartDataWorkbook;

// chart.ChartData.Series.Clear();
// chart.ChartData.Categories.Clear();
IChartSeries series1 = chart.ChartData.Series[0];
IChartSeries series2= chart.ChartData.Series[1];
IChartSeries series3 = chart.ChartData.Series[2];
IChartSeries series4 = chart.ChartData.Series[3];

Using this if i add series4 it gives an error. How can i add 10 series as per my requirement?


I have observed your requirements and like to share that there is no limit of adding 10 series in charts. Can you please try using Aspose.Slides for .NET 16.12.0 on your end and if there is still an issue please provide the source presentation file with us so that I may try reproducing issue.

Many Thanks,