C# ASP.NET图表助手的自定义标题字体

C# ASP.NET图表助手的自定义标题字体,c#,asp.net,charts,fonts,C#,Asp.net,Charts,Fonts,我一直在搜索如何更改asp.net项目图表中标题的字体,但我找不到在代码(控制器代码)中实现图表时更改字体的方法: FooGetChart函数= return new Chart(1200, 600, ChartTheme.Vanilla3D) .AddLegend("foo") .AddTitle("foo")//This is the font I want to change .AddSerie

我一直在搜索如何更改asp.net项目图表中标题的字体,但我找不到在代码(控制器代码)中实现图表时更改字体的方法:

FooGetChart函数=

return new Chart(1200, 600, ChartTheme.Vanilla3D)
                .AddLegend("foo")
                .AddTitle("foo")//This is the font I want to change
                .AddSeries(
                    name: "foo",
                    chartType: "Pie",
                    xValue: groupsList.ToArray(),
                    yValues: groupsCount.ToArray());
我认为:

@Model.Chart.Write(format: "png")
我确信这是一个简单的东西,我无法设法找到,或者我必须重新编码整个事情


谢谢

Title Title=Chart1.Titles.添加(“测试”);
title.Font=新系统.Drawing.Font(“Arial”,16,FontStyle.Bold)

您必须提供自己的自定义XML主题文件:

MyTheme4.xml:

<?xml version="1.0" encoding="utf-8" ?>
<Chart>
  <Titles>
    <Title Name="Title1" ForeColor="LightBlue"  Font="Comic Sans, 32pt, style=Italic">
    </Title>
  </Titles>
</Chart>
return new Chart(width: 600, height: 300, themePath: "MyTheme4.xml")
            .AddTitle("My Custom Chart Title", "Title1") //This is the font I want to change
            .AddSeries(
                chartType: "Pie",
                xValue: new[] { 1, 2, 3, 4, 5 },
                yValues: new[] {10,20,30,40,50});

System.Web.Helpers.Chart仅对.Titles没有定义。AddTitlemodel.Font=新系统.Drawing.Font(“Arial”,16,FontStyle.Bold);ChartViewModel代码是:使用System.Web.Helpers;名称空间视图模型{public class ChartViewModel{public Chart Chart{get;set;}}}}},所以这在银行中不起作用!我决定改用chartjs,但谢谢:)
return new Chart(width: 600, height: 300, themePath: "MyTheme4.xml")
            .AddTitle("My Custom Chart Title", "Title1") //This is the font I want to change
            .AddSeries(
                chartType: "Pie",
                xValue: new[] { 1, 2, 3, 4, 5 },
                yValues: new[] {10,20,30,40,50});