when using the chart helper in MVC5, how can I set a background image to the chart? There is a Chart.BackImage Property in the "original" Chart control. Is the helper only a small subset or is there a way to assign it with themes?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Use a template, as follows:
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();
You can also place the BackImage
attribute in the Chart
tag:
<Chart BackImage=\"/Content/Images/chart.jpg\">...</Chart>