@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