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