New to Telerik UI for ASP.NET Core? Download free 30-day trial

Binding to grouped data

Loading Demo...
  • EXAMPLE
  • VIEW SOURCE
  • Edit in Theme Builder
  • grouped_data.cshtml
  • Grouped_DataController.cs
  • StockDataPoint.cs
  • ChartDataRepository.cs

Also available for:

API REFERENCE

Description

Telerik Core charting extension can be integrated to a grouped data by ASP.NET Core DataSource. To do, so you can follow the steps below:

  1. Bind the chart to a ASP.NET Core DataSource control.
  2. Set the DataSource.group.field property to the name (e.g., the “Symbol” field) of the column in the underlying data which will be the criteria for grouping the chart series items into series Group(group => group.Add(model => model.Symbol)
  3. Bind the Y values of the series to the corresponding data source field (e.g., the “Close” field): series.Area(model => model.Close)
  4. Bind the Category Axis to the corresponding field (e.g., the “Date” field): .Categories(model => model.Date)


This will result in as many series as the number of distinct values in the DataSource.group.field column (e.g., “Symbol”).  Since the “Symbol” field in this example contains three distinct values (“1. GOOG (close)”, “2. AAPL (close)” and “3. AMZN (close)”) the chart will create three series as well.

Support & Learning Resources