Your search did not match any results.

Charts - Server-Side Data Processing

DevExtreme Chart supports remote data processing. In this demo, the component loads weather data for a specified month from an ASP.NET backend service. When you change a month in the drop down, the Chart component sends a new query to update displayed data.

www.wikipedia.org
Backend API
@model IEnumerable<DevExtreme.NETCore.Demos.Models.SampleData.MonthName> @(Html.DevExtreme().Chart() .ID("chart") .DataSource(d => d.Mvc() .Controller("TemperatureData") .LoadAction("Get") .OnBeforeSend("onBeforeSend") .OnLoaded("onLoaded") ) .Title("Temperature in Seattle, 2017") .Size(s => s.Height(420)) .Series(s => s.Add() .ArgumentField("Date") .ValueField("Temperature") .Type(SeriesType.Spline) ) .Legend(l => l.Visible(false)) .CommonPaneSettings(s => s .Border(b => b .Visible(true) .Width(2) .Top(false) .Right(false) ) ) .Export(e => e.Enabled(true)) .Tooltip(t => t .Enabled(true) .CustomizeTooltip(@<text> function(arg) { return { text: arg.valueText + "&#176C" }; } </text>) ) .ValueAxis(a => a .Add() .ValueType(ChartDataType.Numeric) .Grid(g => g.Opacity(0.2)) .Label(l => l .CustomizeText(@<text> function() { return this.valueText + "&#176C"; } </text>) ) ) .ArgumentAxis(a => a .Type(AxisScaleType.Discrete) .Grid(g => g .Visible(true) .Opacity(0.5) ) .Label(l => l .CustomizeText(@<text> function() { return new Date(this.value).getDate();; } </text>) ) ) .LoadingIndicator(l => l.Enabled(true)) ) <div class="action"> <div class="monthlabel">Choose a month:</div> @(Html.DevExtreme().SelectBox() .ID("selectbox") .Width(150) .DataSource(Model) .InputAttr("aria-label", "Month") .Value(new JS("selectedMonth")) .ValueExpr("Id") .DisplayExpr("Name") .OnValueChanged("onSelectBoxValueChanged") ) </div> <script> const year = 2017; let selectedMonth = 1; let startDate = "01/01/2017"; let endDate = "01/31/2017"; const startOfMonthStr = (month) => `${month}/01/${year}`; const endOfMonthStr = (month) => { const nextMonth = (month === 12) ? 1 : month + 1; const nextYear = (month === 12) ? year + 1 : year; const lastDay = new Date(nextYear, nextMonth - 1, 0).getDate(); return `${month}/${lastDay}/${year}`; }; function onBeforeSend(_, ajaxSettings) { const startVisible = startOfMonthStr(selectedMonth); const endVisible = endOfMonthStr(selectedMonth); const startBound = startVisible; const endBound = endVisible; ajaxSettings.data = { startVisible, endVisible, startBound, endBound, }; } function onLoaded(loadResult) { loadResult.forEach(function(element) { element.Date = new Date(element.Date); element.Temperature = (element.MinTemp + element.MaxTemp) / 2; }); } function onSelectBoxValueChanged(e) { selectedMonth = e.value; const chart = $("#chart").dxChart("instance"); chart.refresh(); } </script>
using DevExtreme.AspNet.Data; using DevExtreme.AspNet.Mvc; using DevExtreme.NETCore.Demos.Models; using DevExtreme.NETCore.Demos.Models.SampleData; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; namespace DevExtreme.NETCore.Demos.Controllers { public class ChartsController : Controller { public ActionResult ServerSideDataProcessing() { return View(SampleData.MonthNames); } } }
using DevExtreme.NETCore.Demos.Models; using DevExtreme.NETCore.Demos.Models.SampleData; using Microsoft.AspNetCore.Mvc; using System; using System.Collections.Generic; using System.Linq; namespace DevExtreme.NETCore.Demos.Controllers.ApiControllers { [Route("api/[controller]")] public class TemperatureDataController : Controller { [HttpGet] public IEnumerable<TemperatureItem> Get(string startVisible = "01/01/2017", string endVisible = "12/31/2017", string startBound = "01/01/2017", string endBound = "12/31/2017") { var totalList = SampleData.GetTemperatureRepository(); var startVisibleDate = DateTime.Parse(startVisible); var endVisibleDate = DateTime.Parse(endVisible); var startBoundDate = string.IsNullOrEmpty(startBound) ? DateTime.MaxValue : DateTime.Parse(startBound); var endBoundDate = string.IsNullOrEmpty(endBound) ? DateTime.MinValue : DateTime.Parse(endBound); var startDate = startVisibleDate.AddDays(-7); if(startDate < startBoundDate) { startDate = startBoundDate; } var endDate = endVisibleDate.AddDays(7); if(endDate > endBoundDate) { endDate = endBoundDate; } return totalList.Where(t => t.Date >= startDate && t.Date <= endDate); } } }
using System.Collections.Generic; namespace DevExtreme.NETCore.Demos.Models.SampleData { public class MonthName { public int Id { get; set; } public string Name { get; set; } } public partial class SampleData { public static readonly IEnumerable<MonthName> MonthNames = new[]{ new MonthName { Id = 1, Name = "January" }, new MonthName { Id = 2, Name = "February" }, new MonthName { Id = 3, Name = "March" }, new MonthName { Id = 4, Name = "April" }, new MonthName { Id = 5, Name = "May" }, new MonthName { Id = 6, Name = "June" }, new MonthName { Id = 7, Name = "July" }, new MonthName { Id = 8, Name = "August" }, new MonthName { Id = 9, Name = "September" }, new MonthName { Id = 10, Name = "October" }, new MonthName { Id = 11, Name = "November" }, new MonthName { Id = 12, Name = "December" } }; } }
.action { width: 270px; margin-top: 20px; display: flex; justify-content: space-between; align-items: center; }

To bind data from a remote source, the demo implements a CustomStore (within a DataSource object) and fetches data using the load method. To process data on the server, the ASP.NET backend service is configured to accept processing operations in each request. For backend implementation details, refer to TemperatureDataController.cs in the ASP.NET Core version of this demo: Server-Side Data Processing - ASP.NET Core Charts.

You can shape data within the DataSource as needed (for instance, apply a filter). Disable the paginate property to prevent data partitioning.

A 1-Click Solution for CRUD Web API Services with Role-based Access Control via EF Core

If you target .NET for your backend API, be sure to check out Web API Service and register your free copy today. The Template Kit scaffolds an OData v4 Web API Service (.NET 8+) with integrated authorization & CRUD operations powered by EF Core ORM. You can use OAuth2, JWT or custom authentication strategies alongside tools like Postman or Swagger (OpenAPI) for API testing. The built-in Web API Service also filters out secured server data based on permissions granted to users. Advanced/enterprise functions include audit trail, endpoints to download reports, file attachments, check validation, obtain localized captions, etc.

To use the free Template Kit (which creates the Web API Service), run the Universal Component Installer from the DevExpress Download Manager and use our predefined template in Visual Studio 2022+.

Read Tutorial | View Examples: JavaScript (DevExtreme) & JavaScript (Svelte) | Watch Videos