Hola人回到这里,我怀疑将JSON传递给这两个变量以便动态创建我的图表。 这就是我传递价值的方式: 要填写的字段包括:类别和数据
Public ActionResult Index()
{
DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart")
.SetXAxis(new XAxis
{
Categories = new[] { "Jan", "Feb" }
})
.SetSeries(new Series
{
Data = new Data(new object[] { 29.9, 71.5})
});
return View(chart);
}
我的想法或多或少是创建JSON:
public JsonResult GetPedidoLocalidad()
{
var data = GetDatosLoc();
return Json(data, JsonRequestBehavior.AllowGet);
//return data;
}
private List<EstadisticaViewModels> GetDatosLoc()
{
var allData = (from p in db.Pedidos.Include("Localidad")
group p by p.Localidad.Nombre into pedGrupo
select new EstadisticaViewModels()
{
Nombre = pedGrupo.Key,
Cantidad = pedGrupo.Count()
});
var OrderData = allData.ToList();
return OrderData;
}
我正在使用此示例: DotNetHighcharts