Free Support Forum - aspose.com

Label position in Column Chart

Dear,


I am using ASPose.Slide version 6.7.0.0 to generate a pptx PowerPoint document. I added a column chart. I set the Data Labels position to InsedeEnd but seems it does not work. Kindly find bellow the code I am using.

private void CreateSlide()
{
int slideIndex = pres.Slides.AddEmptySlide(pres.LayoutSlides[1]);
SlideEx sld = pres.Slides[slideIndex];

ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.ClusteredColumn, 0, 200, 720, 300);
chart.ChartTitle.Text.Text = " ";
chart.ChartTitle.Text.CenterText = true;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;
chart.ChartData.Series[0].Labels.ShowValue = true;
chart.ValueAxis.IsVisible = false;
chart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.NoFill;
chart.CategoryAxis.MajorGridLines.Style = LineStyleEx.ThickBetweenThin;

ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
chart.HasLegend = false;
chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), chart.Type);

ChartSeriesEx series = chart.ChartData.Series[0];
series.Format.Fill.FillType = FillTypeEx.Solid;
series.Format.Fill.SolidFillColor.Color = Color.LightGray;

decimal[] values = {10, 11, 48, 65, 22, 24, 89, 60};
for (int i = 0; i < values.Length; i++)
{
chart.ChartData.Categories.Add(fact.GetCell(0, i + 1, 0, values[i]));
series.Values.Add(fact.GetCell(0, i + 1, 1, values[i]));
}

for (int i = 0; i < values.Length; i++)
{
AddLegentToClusterColumnSeries(series, values[i].ToString(), i);
}
}

private void AddLegentToClusterColumnSeries(ChartSeriesEx series, string text, int id)
{
DataLabelEx lbl = new DataLabelEx(series);
lbl.TextFrame.Text = text;

lbl.Position = LegendDataLabelPositionEx.InsideEnd; //here is the how i set the labels position

for (int i = 0; i < lbl.TextFrame.Paragraphs.Count; i++)
{
PortionFormatEx pt = lbl.TextFrame.Paragraphs[i].Portions[0].PortionFormat;
pt.FontHeight = 12;
pt.LatinFont = new FontDataEx(“Century Gothic”);
pt.FontBold = NullableBool.True;
pt.FillFormat.FillType = FillTypeEx.Solid;
pt.FillFormat.SolidFillColor.Color = Color.Black;
}
lbl.Id = id;
series.Labels.Add(lbl);
}

Is there something wrong with my code? Why the labels position is not set to InsideEnd?

Thank you so much,
Sami Simon

Hi Sami Simon,


I have worked with the sample code shared by you and have been able to reproduce the issue. It seems to be an issue with Aspose.Slides. An issue with ID SLIDESNET-33782 has been created in our issue tracking system to further investigate and resolve the issue. This thread has been linked with the issue so that you may be automatically notified once the issue will be resolved.

We are sorry for your inconvenience,

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


This message was posted using Notification2Forum from Downloads module by aspose.notifier.