Pie Chart label formatting + title issue

Dear,


Kindly find bellow the code I am using to create a simple pie chart using aspose.slide 8.4:

public void CreateSlide()
{
SlideEx sld = pres.Slides[0];
Aspose.Slides.Pptx.ChartEx chart = sld.Shapes.AddChart(ChartTypeEx.Pie, 10, 60, 600, 400);
ChartDataCellFactory fact = chart.ChartData.ChartDataCellFactory;
chart.HasLegend = false;
chart.HasTitle = false;
chart.ChartData.Series.Clear();
chart.ChartData.Categories.Clear();
chart.PlotArea.Height = 0.6f;
chart.PlotArea.Width = 0.6f;
chart.PlotArea.X = 0.3f;
chart.PlotArea.Y = 0.25f;
chart.ChartData.Categories.Add(fact.GetCell(0, 1, 0, “C1”));
chart.ChartData.Categories.Add(fact.GetCell(0, 2, 0, “C2”));
chart.ChartData.Categories.Add(fact.GetCell(0, 3, 0, “C3”));
chart.ChartData.Series.Add(fact.GetCell(0, 0, 1, “Series 1”), chart.Type);
ChartSeriesEx series = chart.ChartData.Series[0];
series.Values.Add(fact.GetCell(0, 1, 1, 24));
series.Values.Add(fact.GetCell(0, 2, 1, 74));
series.Values.Add(fact.GetCell(0, 3, 1, 25));
for (int i = 0; i < 3; i++)
{
AddLegentToSeries(series, i);
}
}
private void AddLegentToSeries(ChartSeriesEx series, int id)
{
DataLabelEx lbl;
lbl = new DataLabelEx(series);
lbl.Position = LegendDataLabelPositionEx.OutsideEnd;
lbl.ShowPercentage = true;
lbl.ShowCategoryName = true;
lbl.Separator = " ";
lbl.Id = id;
for (int i = 0; i < lbl.TextFrame.Paragraphs.Count; i++)
{
PortionFormatEx pt = lbl.TextFrame.Paragraphs[i].ParagraphFormat.DefaultPortionFormat;
pt.LatinFont = new FontDataEx(“Century Gothic”);
pt.FontBold = NullableBool.False;
pt.FontHeight = 10;
pt.FillFormat.FillType = FillTypeEx.Solid;
pt.FillFormat.SolidFillColor.Color = Color.Red;
}
series.Labels.Add(lbl);
}

from the resulting presentation we can observe 2 issues:
1- although I have set the following: chart.HasTitle = false; the chart still have a title (series 1)
2- the series labels are not formatted as per: color = red and fontHeight=10

Could you please advise why I am having these 2 issues.

Thank you in advance,
Sami Simon

Hi Sami,

Thank you for sharing the details.

ybatsh:

1- although I have set the following: chart.HasTitle = false; the chart still have a title (series 1)

I am unable to reproduce the above issue using the latest version of Aspose.Slides for .NET v8.3.0. I have attached the resultant presentation file for reference. Please share your resultant presentation file with us and your environment details i.e. OS, .NET Framework etc. with us for further testing.

ybatsh:

2- the series labels are not formatted as per: color = red and fontHeight=10

Please see the following modified code for method “AddLegentToSeries”. The bold part in the below method needs to be updated to get your desired results.

private static void AddLegentToSeries(ChartSeriesEx series, int id)
{
    DataLabelEx lbl = new DataLabelEx(series);
    lbl.Position = LegendDataLabelPositionEx.OutsideEnd;
    lbl.ShowPercentage = true;
    lbl.ShowCategoryName = true;
    lbl.Separator = " ";
    lbl.Id = id;

    for (int i = 0; i < lbl.TextFrame.Paragraphs.Count; i++)
    {
        PortionFormatEx pt = lbl.TextProperties.Paragraphs[i].ParagraphFormat.DefaultPortionFormat;
        pt.LatinFont = new FontDataEx("Century Gothic");
        pt.FontBold = NullableBool.False;
        pt.FontHeight = 10;
        pt.FillFormat.FillType = FillTypeEx.Solid;
        pt.FillFormat.SolidFillColor.Color = Color.Red;
    }

    series.Labels.Add(lbl);
}

In case you still face any issue, please feel free to contact support.

Thanks & Regards,

Dear,


Thank you for your quick response.
I tried the code provided in your last message (PortionFormatEx pt = lbl.TextProperties.Paragraphs[i].ParagraphFormat.DefaultPortionFormat;) and it is working great on my side.

Regarding the first point, I opened the presentation attached in your previous email using “Microsoft PowerPoint 2007” and using “Microsoft PowerPoint 2010” and still was able to see the chart title, kindly find attached “Chart title.png” screenshot.

Regards,
Sami Simon

Hi Sami,

Thanks you for the details and feedback.

Regarding the title issue, I was not able to see the title on the machine with only MS PowerPoint 2010 installed. I checked it on another machine with MS PowerPoint 2007 and I am able to see the title. I have registered the issue in our issue tracking system with issue id: SLIDESNET-34988 for further investigation. This thread is linked to the issue in our issue tracking system and your will be notified once the issue gets resolved.

Thanks & Regards,

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


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

The issues you have found earlier (filed as ) have been fixed in this update. This message was posted using BugNotificationTool from Downloads module by MuzammilKhan