朋友我是highchart
的新手,需要您的帮助才能在MVC 4
创建图表,我在家庭控制器上编写代码就像......
public class HomeController : Controller
{
public ActionResult Index()
{
Highcharts chart = new Highcharts("chart")
.SetCredits(new Credits { Enabled = false })
.InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
.SetTitle(new Title { Text = "Membership Overview" })
.SetXAxis(new XAxis { Categories = new[] { "Paid Members", "Active Members", "Retained Members", "New Members", "Lapsed Members" } })
.SetYAxis(new YAxis
{
Min = 0,
Title = new YAxisTitle { Text = "Total Members" }
})
.SetTooltip(new Tooltip { Formatter = "function() { return ''+ this.series.name +': '+ this.y +''; }" })
.SetPlotOptions(new PlotOptions { Bar = new PlotOptionsBar { Stacking = Stackings.Normal } })
.SetSeries(new[]
{
new Series { Name = "Total", Data = new Data(new object[] { 441, 441, 22, 30, 610 }) }
});
return View(chart);
}
}
现在我不明白如何在index.cshtml
页面上呈现它。
答案 0 :(得分:0)
您的Index.cshtml页面应如下所示,以显示您的图表。
@model DotNet.Highcharts.Highcharts
@{
var chart = Model;
}
if(Model != null) {
@(chart)
}