Your search did not match any results.

Server-Side Data Processing

In many cases, you need to process data on the server before a chart displays it. The Chart component supports this scenario.

In this demo, the data source of the Chart loads weather data for a selected month from an OData service. Each time you select a different month in the drop-down menu, the data source sends a new query to the service. To implement this functionality, assign a DataSource object to the Chart's dataSource property.

In the DataSource, implement the ODataStore. An OData service can include multiple entity collections related to each other, but the ODataStore specifies only one collection. To load multiple collections at once, set the expand property to an array with the additional collection titles. Then, call the postProcess function to process additional data.

Set the paginate property to false to prevent data from partitioning. You can also apply a filter to the received values.

Once you load the data, specify the series type and its nested options (argumentField and valueField), so the component can determine the objects that indicate Chart arguments and values in the data source.

www.wikipedia.org
Backend API
@model IEnumerable<DevExtreme.MVC.Demos.Models.SampleData.MonthName> @(Html.DevExtreme().Chart() .ID("chart") .DataSource(d => d.OData() .Url("https://js.devexpress.com/Demos/WidgetsGallery/odata/WeatherItems") .Expand("DayItems") ) .DataSourceOptions(o => o .PostProcess("function(d) { return d[0].DayItems; }") .Filter(@"[""Id"", ""="", 1]") ) .Title("Temperature in Seattle , 2017") .Size(s => s.Height(420)) .Series(s => s.Add() .ArgumentField("Number") .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) ) ) .LoadingIndicator(l => l.Enabled(true)) ) <div class="action"> <div class="monthlabel">Choose a month:</div> @(Html.DevExtreme().SelectBox() .ID("selectbox") .Width(150) .DataSource(Model) .Value(1) .ValueExpr("Id") .DisplayExpr("Name") .OnValueChanged(@<text> function(data) { var dataSource = $("#chart").dxChart("getDataSource"); dataSource.filter(["Id", "=", data.value]); dataSource.load(); } </text>) ) </div>
using DevExtreme.AspNet.Data; using DevExtreme.AspNet.Mvc; using DevExtreme.MVC.Demos.Models.SampleData; using Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; using System.Web.Mvc; namespace DevExtreme.MVC.Demos.Controllers { public class ChartsController : Controller { public ActionResult ServerSideDataProcessing() { return View(SampleData.MonthNames); } } }
using System; using System.Collections.Generic; namespace DevExtreme.MVC.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; }