Binding controller data to kendo chart


Binding controller data to kendo chart



I am using Kendo Chart with MVC.
The model is


public class DailyProduction
{
public DateTime ProductionDate { get; set; }
public double Value { get; set; }
}



The action controller is


public ActionResult DailyProduction([DataSourceRequest]DataSourceRequest request)
{
List<DailyProduction> dailyProduction = new List<DailyProduction>();
dailyProduction.Add(new DailyProduction (DateTime.Today.AddDays(-3), 10));
dailyProduction.Add(new DailyProduction (DateTime.Today.AddDays(-2), 20));
dailyProduction.Add(new DailyProduction (DateTime.Today.AddDays(-1), 30));

return Json(dailyProduction.ToDataSourceResult(request));
}



The kendo chart in the view is


@(Html.Kendo().Chart<Origin.DTO.DailyProduction>()
.Name("Chart")
.AutoBind(true)
.DataSource(ds => ds.Read(read => read.Action("DailyProduction", "Production"))
)
.Series(series =>
{
series.Column(model => model.ProductionDate);
})
.CategoryAxis(axis => axis.Categories(model => model.Value)
)
)



I want to display the values by production dates.
With this setup, The chart isn't displayed.
The result should be like this



enter image description here



Can someone help me find the solution?









By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Comments

Popular posts from this blog

paramiko-expect timeout is happening after executing the command

Export result set on Dbeaver to CSV

Opening a url is failing in Swift