背景图像与图表控件/帮助程序在剃刀
本文关键字:帮助程序 剃刀 控件 图像 背景 | 更新日期: 2023-09-27 18:32:30
在 MVC5 中使用图表助手时,如何为图表设置背景图像?在"原始"图表控件中有一个 Chart.BackImage 属性。帮助程序只是一小部分,还是有办法为其分配主题?
使用模板,如下所示:
string template = @"<Chart>
<ChartAreas>
<ChartArea Name=""Default"" BackImage=""/Content/Images/chart.jpg"">
</ChartArea>
</ChartAreas>
</Chart>";
var myChart = new Chart(width: 600, height: 400, theme: template)
.AddTitle("Title")
.AddSeries(
name: "Values",
xValue: new[] { "A", "B", "C", "D", "E" },
yValues: new[] { "1", "2", "3", "4", "5" })
.Write();
您还可以将 BackImage
属性放在 Chart
标记中:
<Chart BackImage='"/Content/Images/chart.jpg'">...</Chart>