This is just one example of the many iterations I tried. Essentially, I want to show a pie chart with job types by cost amount. I am able to connect to the database fine, I was able to successfully make a Kendo grid. Any and all help is appreciated!
Report.cshtml
@(Html.Kendo().Chart<JobWebApp.Models.JobViewModel>()
.Name("piechart")
.Title("Job Types to Cost")
.DataSource(dataSource => dataSource
.Read(read => read.Action("Jobs_Read", "Reports").Type(HttpVerbs.Get))
)
.Legend(legend => legend
.Position(ChartLegendPosition.Top)
)
.Series(series =>
{
series.Pie(
x => x.JOB_TYPE,
x => x.JOB_COST
);
})
)
ReportsController.cs
[HttpGet]
public ActionResult Jobs_Read([DataSourceRequest]DataSourceRequest request)
{
return Json(GetJobs().ToDataSourceResult(request), JsonRequestBehavior.AllowGet);
}
[NonAction]
private IQueryable<JobViewModel> GetJobs()
{
return from job in dbEntities.Jobs
select new JobViewModel
{
ID = job.ID,
DATE = job.DATE,
JOB_TYPE = job.JOB_TYPE,
JOB_COST = job.JOB_COST
};
}
Flip your values around for the pie chart series data:
The method signature is this:
IIRC, kendo only accepts numeric values for the expressionValue parameter.