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 30, 2022 9:52 am

I'm guessing this will probably be impossible but wanted to check.

Is there a way to read a given datalabel's position (horizontal and vertical) on a slide?

I would like to add a textbox which is relative to the position of the given datalabel.

See before and after images attached.

Before
Before1.PNG


After
After1.PNG

majeed_s
 
Posts: 69
Joined: Thu Mar 25, 2021 4:13 pm

Thu Mar 31, 2022 10:46 am

Hi,

Thank you for your inquiry.
According to the picture you provided, I noticed that the data label is added by default in your chart. Sorry for the truth that our Spire.Presentation cannot get its coordinate position because there is no position information of default data label written into the document data. But if you manually move the location of data label, the position information would be written into the document, and you can use the code below to get the position of data label. If there is any question, please provide your input Powerpoint for further investigation.
Code: Select all
            IChart chart = ppt.Slides[0].Shapes[0] as IChart;
            ChartDataLabelCollection dataLabels1 = chart.Series[0].DataLabels;       
            ChartDataLabel label = dataLabels1[0];       
            float x=label.X;
            float y= label.Y;


Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Tue Apr 19, 2022 2:09 pm

How can I add another shape according to the X and Y positions of a data label? Because these X and Y positions look like relative positions and I need absolute position or I need to add another shape relatively data label X and Y position.

omur.ertanis
 
Posts: 22
Joined: Mon Feb 21, 2022 6:49 am

Wed Apr 20, 2022 10:36 am

Hi,

Thank you for your feedback.
Kindly note the X,Y of the data label is relative to the default label position, but the shape position is relative to the entire slide. Sorry there is no good way to add a shape according to the position of data label. If you have other question, please feel free to contact us.

Sincerely,
Kylie
E-iceblue support team
User avatar

kylie.tian
 
Posts: 412
Joined: Mon Mar 07, 2022 2:30 am

Return to Spire.Presentation