我正在从我的控制器返回一个 josn 数据并将其绑定到饼图......但最后我在我的页面中没有得到任何东西......谁能告诉我我在哪里做错了......
<script type="text/javascript">
$(function () {
var chart;
alert('1');
$(document).ready(function () {
var options = {
chart: {
renderTo: 'container',
plotBackgroundColor: null,
plotBorderWidth: null,
plotShadow: false,
defaultSeriesType: 'pie'
},
title: {
text:'Resource Reports'
},
plotOptions: {
pie: {
allowPointSelect: true,
cursor: 'pointer',
dataLabels: {
enabled: true,
color: '#000000',
connectorColor: '#000000',
formatter: function () {
//return '<b>' + this.point.name + '</b>: ' + this.percentage + ' %';
}
}
}
},
series: [{
type: 'pie',
name: 'Fruits',
data:[]
}]
};
$.getJSON('<%= Url.Action("GetData","JqueryCharts") %>', null, function (data) {
alert('2');
options.series = json;
chart = new Highcharts.chart(options);
});
});
});
</script>
这是我的控制器
public JsonResult GetData()
{
//int Param1;
//Param1 = 1;
//DataEntitiesModel data = new DataEntitiesModel();
//var procedure=db.Database.SqlQuery<DataEntitiesModel>("ResourceReports @EmployeeID",new SqlParameter("@EmployeeID", Param1) );
//var procedure = db.Database.SqlQuery<DataEntitiesModel>("Select * from EmployeeDetails");
//var data = db.ProjectReports.ToList().Select( e => new
//{
// Id = e.EmployeeID,
// Name = e.EmployeeName
//});
var EmployeeDetails = db.EmployeeDetails.ToList<EmployeeDetail>().Select(e => new
{
id=e.EmployeId,
Name = e.EmployeeName
});
return Json(EmployeeDetails, JsonRequestBehavior.AllowGet);
}