Background image with chart control / helper in Ra

2019-09-14 00:38发布

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条回答
干净又极端
2楼-- · 2019-09-14 01:06

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>
查看更多
登录 后发表回答