Replacing series data labels with textboxes

Hello. I have a scatter line chart and my requirement is to replace the series data labels with textboxes placed on top of the chart. Is this possible?


Thanks.

Hi Brian,


I have observed your comments. Can you please share what you want to achieve in form of presentation so that we can investigate to help you out.

Best Regards,

In the attached presentation, the first slide has the datalabels based on the series data for the chart. What I need to do is loop through these labels and replace them with textboxes placed on top of the chart as in the second slide.


Thanks.

Hi Brian,


I have observed your comments and like to share that you can add autoshape with text box inside a chart but there is an issue in using that in your implementation. The series data points are rendered based on data and size of charts by charting engine on runtime. Owing to this reason, you may not be able to set the position of your desired textframe label for chart datapoint. However, Aspose.Sldies offers you to set the custom data for chart series data point label as well. If custom label is your intended requirement then you can try using following sample code in your application to serve the purpose. I hope the shared information will be helpful.

chart.ChartData.Series[0].DataPoints[0].Label.TextFrameForOverriding.Text = “New text”;

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 9.5px Helvetica} span.s1 {color: #b4261a}



Many Thanks,

The problem that I am trying to solve is being able to select all or multiple data labels using the mouse to create a selection (see attachment). Is there any way to do this?

Hi Brian,


I regret to inform that it is not possible is Aspose.Slides. Aspose.Slides has no user interface so that’s why you can not select with mouse. The best answer for this was shared by our colleague in above reply for this. Please share feedback with us if there is still an issue.

Best Regards,

Is there no way to get the position of a datalabel on a chart after it has been plotted?


Thanks.

Hi Brian,

I have observed the requirements shared by you and like to share that Aspose.Slides does allow you to alter the label X and Y position inside chart area. The position X,Y coordinates are relative to actual default position of the label where PowerPoint sets that. Please try using the following sample code on your end to get an idea as it might help in achieving your target.

public static void AddChartLab()
{
Presentation pres=new Presentation (@“C:\Aspose Data\Labels.pptx”);

IChart chart=(IChart)pres.Slides[0].Shapes[0];
double label1X = chart.ChartData.Series[0].DataPoints[0].Label.X;
double label1Y = chart.ChartData.Series[0].DataPoints[0].Label.Y;

double label2X = chart.ChartData.Series[0].DataPoints[1].Label.X;
double label2Y = chart.ChartData.Series[0].DataPoints[1].Label.Y;

double label3X = chart.ChartData.Series[0].DataPoints[2].Label.X;
double label3Y = chart.ChartData.Series[0].DataPoints[2].Label.Y;
chart.ChartData.Series[0].DataPoints[0].Label.X = 0;
chart.ChartData.Series[0].DataPoints[0].Label.Y = 0;

pres.Save(@“C:\Aspose Data\Labels2.pptx”, SaveFormat.Pptx);
}

Many Thanks,

double label1X = chart.ChartData.Series[0].DataPoints[0].Label.X;
double label1Y = chart.ChartData.Series[0].DataPoints[0].Label.Y;


returns NaN

Hi Brian,

NaN is returned in cases where the default position of labels is used. You can set your own value for the label by setting X and Y. If you please refer to example presentation that I have shared, I have used different location for each label in chart and hence its X,Y value is appearing. I hope this will clarify the concept.

Many Thanks,

But that doesn’t solve my issue. I need to be able to either A) get the x and y of the data label relative to the slide, not the chart so that I can place a shape in the same location, or B) put the data labels on top of chart so that multiple labels can be selected at once. There has got to be some way to do this??

Hi Brian,

I have observed your comments and like to share that for your point A, I have shared earlier with you as well that at present you can get X,Y position relative to chart plot area as data points are rendered by charting engine on runtime. However, we have already logged an issue with ID SLIDESNET-37586 to provide the support for getting absolute position of chart data point. Once this support will be available in upcoming Aspose.Slides for .NET 17.3.0 product release, you will be able to use that as per your requirements.

For your point B, I like to suggest that you may set the negative value of Y for any chart label in code sample shared by me. You may use try setting different Y values and select the one suiting your requirement for the time being.

Your requirements will be well addressed when issue SLIDESNET-37586 will be fixed. We will share the notification with you once the product will be available online by end of this month.

Many Thanks,

Thanks so much I look forward to the next version with this feature.

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


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