Spire.Presentation is a professional PowerPoint® compatible library that enables developers to create, read, write, modify, convert and Print PowerPoint documents. Get free and professional technical support for Spire.Presentation for .NET, Java, Android, C++, Python.

Wed Jun 24, 2020 12:18 pm

Hello,

I need to update stacked bar chart values with percentages.

Code: Select all
value = 10;
chart.ChartData[1,1].Value = value;


Please let me know.
Thanks in advance!

Thanks,
Kinali Gandhi

Kinali94
 
Posts: 12
Joined: Mon May 04, 2020 8:46 am

Thu Jun 25, 2020 1:52 am

Hi Kinali,

Thanks for your inquiry.
Please refer to the code snippet below. Also, you can refer to this article: Create 100% stacked bar chart in PowerPoint in C#. If there is any question, please provide your desired output for our reference.
Code: Select all
    for (int columnlabelIndx = 0; columnlabelIndx < columnlabelLength; ++columnlabelIndx)
    {
        for (int rowlabelIndex = 0; rowlabelIndex < rowlabelLength; ++rowlabelIndex)
        {
            //Add data label
            var label = chart.Series[columnlabelIndx].DataLabels.Add();
            label.LabelValueVisible = true;
            //Set number format for data label
            chart.Series[columnlabelIndx].DataLabels[rowlabelIndex].HasDataSource = false;
            chart.Series[columnlabelIndx].DataLabels[rowlabelIndex].NumberFormat = "0#\\%";
        }
    }


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Wed Jul 15, 2020 11:19 am

Hello,

Greetings from E-iceblue!
Has your issue been resolved? Could you please give us some feedback at your convenience?
Thanks in advance.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Jul 21, 2020 9:44 am

Hello,

Thank you so much for your help!

It's working as expected, Only one issue I am facing like:
I want to update values as Negative but don't want to display negative in chart.

for ex: value should be -30% in excel chart details but It should be display like 30% in chart.

Thanks in advance!

Regards,
Kinali Gandhi

Kinali94
 
Posts: 12
Joined: Mon May 04, 2020 8:46 am

Tue Jul 21, 2020 10:38 am

Hi Kinali,

Please refer to the following code snippet. Feel free to contact us if you have further questions.
Code: Select all
chart.Series[c].DataLabels[r].NumberFormat = "0#\\%;0#\\%";


Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Tue Jul 21, 2020 1:15 pm

Thank you for you quick response!

It's working perfect.

Thanks,
Kinali Gandhi

Kinali94
 
Posts: 12
Joined: Mon May 04, 2020 8:46 am

Wed Jul 22, 2020 1:06 am

Hi Kinali,

Glad to hear that!
If you encounter any issues related to our product in the future, just feel free to contact us.
Have a nice day!

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Return to Spire.Presentation