Unable to Change the Font of a Treemap Chart in PowerPoint Presentation in C#

Hi, I can use the following code to change the font of any chart other than a Treemap chart in a powerpoint slide.

chart.TextFormat.PortionFormat.LatinFont = new FontData("Arial");
chart.TextFormat.PortionFormat.FontHeight = 11;

The version of the Aspose.Slides for .NET I used is 21.9.0. How can I change the font of a Treemap chart?

@admangowilson,
Thank you for the issue description. I reproduced the problem with changing the chart font and logged the issue with ID SLIDESNET-42832 in our tracking system. Our development team will investigate this case. You will be notified when the problem is resolved.

@admangowilson,
Our development team has investigated the issue. Unfortunately, the property Chart.TextFormat is not applicable for the following types: ChartType.Treemap, ChartType.Sunburst, ChartType.Waterfall, ChartType.Histogram, ChartType.Funnel and ChartType.BoxAndWhisker. For these types, the text style can’t be set within a chart.

It is a PowerPoint’s interface feature that you can implement as shown below:

using (Presentation pres = new Presentation())
{
    IChart chart = pres.Slides[0].Shapes.AddChart(ChartType.Treemap, 50, 50, 450, 300);

    SetCommonTextStyle(chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.TextFormat);
    SetCommonTextStyle(chart.Legend.TextFormat);
    SetCommonTextStyle(chart.ChartTitle.TextFormat);

    pres.Save(folderPath + "output.pptx", SaveFormat.Pptx);
}
public static void SetCommonTextStyle(IChartTextFormat textFormat)
{
    textFormat.PortionFormat.LatinFont = new FontData("Arial");
    textFormat.PortionFormat.FontHeight = 14;
    textFormat.PortionFormat.FillFormat.FillType = FillType.Solid;
    textFormat.PortionFormat.FillFormat.SolidFillColor.Color = System.Drawing.Color.Green;
}

More examples:
Create Chart
Chart Formatting

I have tried your code, it cannot change the font of the title. I am using the latest Aspose.Slides version 22.1.0.0.

The following is my testing code, it just create a simple tree map chart and add a title then format the font.

static void Main(string[] args)
{
    Aspose.Slides.License license = new Aspose.Slides.License();
    license.SetLicense("Aspose.Slides.NET.lic");

    using (Presentation pres = new Presentation())
    {
        IChart chart = pres.Slides[0].Shapes.AddChart(Aspose.Slides.Charts.ChartType.Treemap, 50, 50, 450, 300);

        chart.ChartTitle.AddTextFrameForOverriding("This is the title");
        chart.ChartTitle.Overlay = false;
        chart.HasTitle = true;

        SetCommonTextStyle(chart.ChartData.Series[0].Labels.DefaultDataLabelFormat.TextFormat);
        SetCommonTextStyle(chart.Legend.TextFormat);
        SetCommonTextStyle(chart.ChartTitle.TextFormat);

        pres.Save("Result.pptx", Aspose.Slides.Export.SaveFormat.Pptx);
    }

}

public static void SetCommonTextStyle(IChartTextFormat textFormat)
{
    textFormat.PortionFormat.LatinFont = new FontData("Arial");
    textFormat.PortionFormat.FontHeight = 8;
    textFormat.PortionFormat.FillFormat.FillType = FillType.Solid;
    textFormat.PortionFormat.FillFormat.SolidFillColor.Color = System.Drawing.Color.Green;
}

@admangowilson,
Thank you for reporting the issue.

I’ve reproduced the problem with formatting the chart title and added a ticket with ID SLIDESNET-43051 in our issue tracking system. We apologize for any inconvenience. Our development team will investigate this case. You will be notified when the issue is resolved.

Any update on this issue?

@admangowilson,
Unfortunately, the issue is still open. It will be fixed according to the terms mentioned in Free Support Policies.

You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.

Thanks for your reply.

If I upgrade to the latest version of Aspose.Slides, will I be able to set the font size of the title in a Treemap chart?

@admangowilson,
The issue is still open. Unfortunately, the latest version of Aspose.Slides does not include a fix at the moment.