Remote Binding
The Chart Wizard supports remote data binding that enables you to load the chart data through a remote endpoint.
For a runnable example, refer to the demo on binding the Chart Wizard to remote data.
To configure the Chart Wizard to bind to data received from a remote endpoint, follow the next steps:
-
Define a Model with the respective properties that must be accessible in the chart (for the axes and series).
C#public class Product { public int ProductID { get; set; } public string ProductName { get; set; } public int Quantity { get; set; } public decimal Price { get; set; } public decimal Tax { get; set; } public decimal Total { get; set; } public decimal TotalTax { get; set; } }
-
Create an Action method and pass data collection to the
ToDataSourceResult()
extension method to convert the collection to aDataSourceResult
object.C#public JsonResult Read([DataSourceRequest] DataSourceRequest request) { return Json(ProductsData().ToDataSourceResult(request)); } private static List<Product> ProductsData() { return new List<Product>() { new Product { ProductID = 216321, ProductName = "Calzone", Quantity = 1 }, new Product { ProductID = 546897, ProductName = "Margarita", Quantity = 2 }, new Product { ProductID = 456231, ProductName = "Pollo Formaggio", Quantity = 1 } }; }
-
Within the
Index.cshtml
View, configure the Chart Wizard to useDataSource
and specify the name of the Action that returns the data in theRead()
option. Also, you must define the Model properties in theDataColumns()
configuration to make them accessible through the chart configurator.Razor@(Html.Kendo().ChartWizard<Product>() .Name("chartwizard") .DataSource(dataSource => dataSource .Read(read => read.Action("Read", "Home")) ) .DataColumns(columns => { columns.Add().Field(f => f.ProductName).Title("Product Name"); columns.Add().Field(f => f.Quantity); }) )