我一直在asp.net项目上搜索如何在图表中更改标题的字体,但找不到通过代码(控制器代码)中的图表实现更改字体的方法:
public ActionResult Foo()
{
var model = new ChartViewModel
{
Chart = FooGetChart() //System.Web.Helpers.Chart
};
return View(model);
}
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")
我敢肯定,这很简单,我无法设法找到某种方式,或者也许我必须重新编码整个内容。
谢谢!
您必须提供自己的自定义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});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句