Formatting Labels of charts

Hi,
Can you please guide me, how i can change text color and size of series label.?
By default size and color is 18pt and black.

ChartSeriesEx series = null;
ChartSeriesEx series1 = null;
ChartSeriesEx series2 = null;
ChartSeriesEx series3 = null;

// chart1

ChartEx chart = pres.Slides[0].Shapes.AddChart(ChartTypeEx.StackedBar, 15, 70, 230, 400);

chart.ChartTitle.Text.Text = " ";
chart.ChartTitle.Text.CenterText = true;
chart.ChartTitle.Height = 20;
chart.HasTitle = true;
chart.ChartFormat.Fill.FillType = FillTypeEx.Solid;
chart.ChartFormat.Fill.SolidFillColor.Color = Color.Transparent;
chart.PlotArea.Format.Fill.FillType = FillTypeEx.Solid;
chart.PlotArea.Format.Fill.SolidFillColor.Color = Color.Transparent;
chart.ValueAxis.IsVisible = false;
chart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.Solid;
chart.ValueAxis.MajorGridLines.FillFormat.SolidFillColor.Color = Color.Blue;
chart.ValueAxis.MajorGridLines.Width = 0;
chart.ValueAxis.IsVisible = false;


chart.ValueAxis.MajorGridLines.FillFormat.FillType = FillTypeEx.NoFill;
chart.ValueAxis.MinorGridLines.FillFormat.FillType = FillTypeEx.NoFill;

int index = 0, c = 0;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();

int defaultWorksheetIndex = 0;
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;

chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, 1, “Total”), chart.Type);
//Adding new categories (Here Month Names are Categories- x-axis)
for (int r = 1; r <= 1; r++)
{

c++;
index = chart.ChartData.Series.Add(fact.GetCell(defaultWorksheetIndex, 0, c, arrlist[0].ToString()), chart.Type);

}
for (int k = 0; k < 4; k++)
{

chart.ChartData.Categories.Add(fact.GetCell(defaultWorksheetIndex, k + 1, 0, Category[k]));
}

int x = chart.ChartData.Categories.Count;


series = chart.ChartData.Series[0];

series.Labels.ShowValue = true;
c = 0;
float total = 0;
for (int r = 1; r <= 1; r++)
{

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

total = 0;
float.TryParse(GridView1.Rows[r - 1].Cells[1].Text, out total);
series.Values.Add(fact.GetCell(0, 1, c + 1, total));

total = 0;
float.TryParse(GridView1.Rows[r - 1].Cells[2].Text, out total);
series.Values.Add(fact.GetCell(0, 2, c + 1, total));

total = 0;
float.TryParse(GridView1.Rows[r - 1].Cells[3].Text, out total);
series.Values.Add(fact.GetCell(0, 3, c + 1, total));

total = 0;
float.TryParse(GridView1.Rows[r - 1].Cells[4].Text, out total);
series.Values.Add(fact.GetCell(0, 4, c + 1, total));


series.Labels.LinkedSource = false;
series.Labels.ShowValue = true;
series.Labels.NumberFormat = “0.00”;
// series.Labels.ShowPercentage = true;

c++;
LegendEx legend = chart.Legend;
legend.Position = LegendPositionTypeEx.Bottom;

}

Hi Amit,


I have observed the requirements shared by you but unfortuantely I am not able to use your sample code as it contain access to custom data on your end. However, I have used the following sample code on my end to set the requested font related properties for the chart series labels. Please try inserting the following code in your sample code where you are working with series labels.

PortionFormatEx format = series.Labels.TextProperties.Paragraphs[0].ParagraphFormat.DefaultPortionFormat;
format.FontHeight = 16;
format.FillFormat.FillType = FillTypeEx.Solid;
format.FillFormat.SolidFillColor.Color = Color.Red;
format.FontBold = NullableBool.True;
format.FontItalic = NullableBool.True;
chart.HasLegend = false;


Please share, if I may help you further in this regard.

Many Thanks,

Hi Mudassir,

Its working, Thanks for your help.

Dear Mudassir,

p: We are exporting a chart into PPT and PDF. In PPT its coming fine whereas when we export the same thing, 1 series is missing. (if we have 4 series then exporting in PDF gives 3 series)

Please help in this matter.

Hi Amit,

I have observed the issue statement shared by you and request you to please share the source presentation along with generated output for reference. I also suggest you to please try using Aspose.Slides for .NET 7.5.1 on your end and share with us if there is still an issue. Please also share the used code sample for reference.

Many Thanks,