Your search did not match any results.

Charts - Simple Array

If you do not need to populate the Chart with data from a remote server, and the data does not change frequently, then bind the component to a local JavaScript array. Pass the array to the Chart's dataSource property.

www.datahub.io
Backend API
@(Html.DevExtreme().Chart() .ID("chart") .DataSource(new JS("populationData")) .Series(s => s .Add() .Type(SeriesType.Bar) ) .Legend(l => l.Visible(false)) .ArgumentAxis(a => a .TickInterval(10) .Label(l => l .Format(f => f .Type(Format.Decimal) ) ) ) .Title("World Population by Decade") ) <script src="~/data/populationData.js"></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 Newtonsoft.Json; using System; using System.Collections.Generic; using System.Linq; namespace DevExtreme.NETCore.Demos.Controllers { public class ChartsController : Controller { public ActionResult SimpleArray() { return View(); } } }
var populationData = [{ arg: 1960, val: 3032019978 }, { arg: 1970, val: 3683676306 }, { arg: 1980, val: 4434021975 }, { arg: 1990, val: 5281340078 }, { arg: 2000, val: 6115108363 }, { arg: 2010, val: 6922947261 }, { arg: 2020, val: 7795000000 }];
#chart { height: 440px; }

Once you assign the data source, specify the series type and its nested options: argumentField and valueField. If you specify these properties, the component can determine the object fields that indicate Chart arguments and values in the array. The default values for these properties are arg and val, respectively. You can use these data field names to structure your array as shown in this demo.