我一直在搜索如何在我的asp.net项目中更改我的图表中标题的字体,我找不到用我的代码中的图表实现来更改字体的方法(控制器代码):
public ActionResult Foo()
{
var model = new ChartViewModel
{
Chart = FooGetChart() //System.Web.Helpers.Chart
};
return View(model);
}
FooGetChart function =
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")
我确信这是一件很简单的事情,我无法以某种方式找到,或者我可能需要重新整理。
谢谢!
答案 0 :(得分:1)
您必须提供自己的自定义XML主题文件:
http://www.w3schools.com/jquery/jquery_css.asp
<强> 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});
答案 1 :(得分:0)
Title title = Chart1.Titles.Add(“Test”); title.Font = new System.Drawing.Font(“Arial”,16,FontStyle.Bold);