JSON Files

If your server stores data in JSON, performing AJAX requests is inevitable. But instead of configuring these requests manually, pass the URL of your data storage (in this demo, a JSON file) to the DataSourceUrl method, and the Chart will do the rest. This URL may specify an absolute or relative path to the resource.

@(Html.DevExpress()
    .BootstrapChart("chartJSON")
    .TitleText("Daily Sales")
    .Rotated(true)
    .ArgumentAxis(axis => axis
        .ArgumentType(typeof(DateTime))
        .MaxValue("2017-01-10"))
    .ValueAxisCollection(axis => axis
        .AddValueAxis()
            .TickInterval(1))
    .SeriesCollection(series => series
        .AddBarSeries()
            .ArgumentField("date")
            .ValueField("sales"))
    .SettingsLegend(settings => settings.Visible(false))
    .Bind("jsondata/simple.json"))

JSONP

You can use a JSONP callback parameter supported by jQuery.ajax() to access a web service that implements a JSONP (JSON with padding) endpoint.

using DevExpress.AspNetCore.DemoModels;
using Microsoft.AspNetCore.Mvc;
using System.Web;
namespace DevExpress.AspNetCore.Demos {
    public partial class ChartController : Controller {
        public IActionResult JSONP() {
            return PartialView("DataBinding/JSONP");
        }
        public IActionResult GetData() {
            string filePath = System.IO.Path.Combine(hostingEnvironment.WebRootPath, "jsondata/medals.json");
            string fileContent = System.IO.File.ReadAllText(filePath);
            var obj = Newtonsoft.Json.JsonConvert.DeserializeObject(fileContent);
            return new JsonResult(obj);
        }
    }
}
Screen Size
Color Themes
Demo QR Code