Show percentage in stacked bar chart

Jul 9, 2013 at 7:15 AM
Edited Jul 9, 2013 at 7:16 AM
Hi All,

I have developed the stacked bar chart using EPPlus and able to show the data label value. But not able to show the percentages for each datalabels. I have tried the "chart.DataLabel.ShowPercent = true;" option to show the percentage, but it's not working

here is the code:
            var chart = Worksheet.Drawings.AddChart("BarStacked", eChartType.BarStacked) as ExcelBarChart;
            chart.Title.Text = "Stacked Bar Chart";
            chart.SetPosition(120, 50);
            chart.SetSize(800, 300);
            chart.Legend.Position = eLegendPosition.Right;
            chart.Legend.Add();
            chart.ShowHiddenData = true;

            chart.DataLabel.ShowValue = true;
            chart.DataLabel.ShowPercent = true;
            var chart = Worksheet.Drawings.AddChart("BarStacked", eChartType.BarStacked) as ExcelBarChart;
            chart.Title.Text = "Stacked Bar Chart";
            chart.SetPosition(120, 50);
            chart.SetSize(800, 300);
            chart.Legend.Position = eLegendPosition.Right;
            chart.Legend.Add();
            chart.ShowHiddenData = true;

            chart.DataLabel.ShowValue = true;
            chart.DataLabel.ShowPercent = true;

            var series1 = chart.Series.Add(Worksheet.Cells["B2:B5"], Worksheet.Cells["B1:E1"]);
            series1.Header = Worksheet.Cells["A2"].Value.ToString();

            var series2 = chart.Series.Add(Worksheet.Cells["C2:C5"], Worksheet.Cells["B1:E1"]);
            series2.Header = Worksheet.Cells["A3"].Value.ToString();

            var series3 = chart.Series.Add(Worksheet.Cells["D2:D5"], Worksheet.Cells["B1:E1"]);
            series3.Header = Worksheet.Cells["A4"].Value.ToString();

            var series4 = chart.Series.Add(Worksheet.Cells["E2:E5"], Worksheet.Cells["B1:E1"]);
            series4.Header = Worksheet.Cells["A5"].Value.ToString();
Please let me know, how to add the percentage on each stack?

Thanks,
Gopi