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 Mar 20, 2024 7:40 am

Hi,
I am trying to create a datalabel with properties shown as in the attachment "fill.jpg" especially the one highlighted in green.
I inspected existing datalabels properties and saw that solidColor.FillType is set to Solid which seems to be the second bullet point in the list and then the solidColor property looks like the one in attachment "solidcolor.jpg".

However when assigning those property to a new datalabel, initially I see the result as expected (transparency is kept together with all the looking of the datalabel) but if I inspect the datalabel it's not showing Solid, it's showing automatic instead.

Now, if I save, close and reopen the file, it doesn't look right and transparency is back to 0 as in postSave.png

Here's the code I am using to set those properties. DatalabelProperties is my custom object where I track existing properties of datalabels retrievining from DefaultCharacterProperties of the label I want to copy from.

Code: Select all
            paragraph.DefaultCharacterProperties.Fill.FillType = dataLabelProperties.FillType;
            paragraph.DefaultCharacterProperties.Fill.SolidColor.Color = dataLabelProperties.SolidColor.Color;


I tried setting both at paragraph level as above and at textRange level as below, result is the same.

Code: Select all
                textRange.Fill.SolidColor.SchemeColor= dataLabelProperties.SolidColor.SchemeColor;
                textRange.Fill.SolidColor.ColorType = dataLabelProperties.SolidColor.ColorType;
                textRange.Fill.SolidColor.Color = dataLabelProperties.SolidColor.Color;


On the textrange I also tried to retain the SchemeColor since it's shown as background1 but it gets cleared as soon as I assign the color and set back to None.

Any hint to solve this issue?

Also the border property is not retained somehow but that doesn't affect the layout. If we could get also a solution to retain without setting it to automatic it would be great!

Thanks in advance,

A

andreacalvi
 
Posts: 23
Joined: Tue Jul 11, 2023 11:02 am

Wed Mar 20, 2024 9:48 am

Hello,

Thanks for your inquriy.
Please refer to the following code to obtain the setting values in the attached screenshot.If there are any misunderstandings, please reply to us with more details about your needs. Alternatively, you can provide us with your testing documents and expected results, and we will further investigate. Thank you in advance.
Code: Select all
Presentation presentation = new Presentation();
presentation.LoadFromFile("test.pptx");
IChart chart = presentation.Slides[0].Shapes[0] as IChart;
ChartDataLabel chartDataLabel = chart.Series[0].DataLabels[0];
Spire.Presentation.Drawing.FillFormatType fillType = chartDataLabel.Fill.FillType;
 Spire.Presentation.Drawing.ColorFormat solidColor = chartDataLabel.Fill.SolidColor;
Spire.Presentation.Drawing.FillFormatType lineType = chartDataLabel.Line.FillType;

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Wed Mar 20, 2024 12:22 pm

Hi William,
that worked to retain line and fill types at datalabel level, thanks.

However, I still have to set the transparency. Result is showing now label back to full white because transparency is 0%.

What is the right property to handle that value?

Thanks!

andreacalvi
 
Posts: 23
Joined: Tue Jul 11, 2023 11:02 am

Thu Mar 21, 2024 1:15 am

Hello,

Thanks for your reply.
Please refer to the following code snippet to set the transparency of the color.
Code: Select all
 Spire.Presentation.Drawing.ColorFormat solidColor = chartDataLabel.Fill.SolidColor;
 float transparency = solidColor.Transparency;

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 454
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.Presentation