Your search did not match any results.
Charts

Server-Side Data Processing

Documentation
In many cases, before being handed out to the client, data is processed on the server. The DevExtreme HTML5 Widgets support this scenario. In this demo, the data source of the Chart widget loads weather data for a selected month from an OData service. Each time the month is changed, the data source sends a new query to the service.
Copy to Codepen
Apply
Reset
window.onload = function() { var currentMonth = ko.observable(undefined), options = { dataSource: [], size: { height: 420 }, series: { argumentField: "Number", valueField: "Temperature", type: "spline" }, legend: { visible: false }, commonPaneSettings: { border: { visible: true, width: 2, top: false, right: false } }, "export": { enabled: true }, tooltip: { enabled: true, customizeTooltip: function (arg) { return { text: arg.valueText + "&#176C" }; } }, valueAxis: { valueType: "numeric", constantLines: [{ value: undefined, width: 2, dashStyle: "dash", color: "#ff7c7c", label: { text: "Highest" } }, { value: undefined, width: 2, dashStyle: "dash", color: "#8c8cff", label: { text: "Lowest" } }, { value: undefined, width: 1, dashStyle: "dash", label: { text: "Average" } }], grid: { opacity: 0.2 }, label: { customizeText: function() { return this.valueText + "&#176C"; } } }, argumentAxis: { type: "discrete", grid: { visible: true, opacity: 0.5 } } }; var chartOptions = ko.observable(options); var monthDataStore = new DevExpress.data.DataSource({ store: { type: "odata", url: "https://js.devexpress.com/Demos/WidgetsGallery/odata/WeatherItems", onLoaded: function(results) { var data = results[0], newOptions = { dataSource: data.DayItems, title: "Temperature in Barcelona: " + data.Name.substr(0, 1).toUpperCase() + data.Name.substr(1) + " 2012", series: { color: data.Color }, valueAxis: { min: data.RecordLow - 1, max: data.RecordHigh + 1, constantLines: [{ value: data.RecordHigh }, { value: data.RecordLow }, { value: data.Average }] } }; chartOptions($.extend(true, {}, options, newOptions)); } }, expand: "DayItems" }); var viewModel = { chartOptions: chartOptions, monthOptions: { width: 150, items: months, value: currentMonth, valueExpr: "id", displayExpr: "name" } }; currentMonth.subscribe(changeMonthData); currentMonth(1); function changeMonthData(monthId) { monthDataStore.filter(["Id", "=", monthId]); monthDataStore.load(); } ko.applyBindings(viewModel, document.getElementById("chart-demo")); };
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>DevExtreme Demo</title> <meta http-equiv="X-UA-Compatible" content="IE=edge" /> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0" /> <script src="js/jquery-3.1.0.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.0/knockout-min.js"></script> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/16.2.5/css/dx.spa.css" /> <link rel="stylesheet" type="text/css" href="https://cdn3.devexpress.com/jslib/16.2.5/css/dx.common.css" /> <link rel="dx-theme" data-theme="generic.light" href="https://cdn3.devexpress.com/jslib/16.2.5/css/dx.light.css" /> <script src="https://cdn3.devexpress.com/jslib/16.2.5/js/dx.all.js"></script> <script src="data.js"></script> <link rel="stylesheet" type ="text/css" href ="styles.css" /> <script src="index.js"></script> </head> <body class="dx-viewport"> <div class="demo-container"> <div id="chart-demo"> <div id="chart" data-bind="dxChart: chartOptions"></div> <div class="action"> <div id="selectbox" data-bind="dxSelectBox: monthOptions"></div> <div class="label">Choose a month:</div> </div> </div> </div> </body> </html>
#chart-demo { width: 100%; } #selectbox { float: right; } .action { width: 270px; margin-top: 20px; } .label { padding-top: 9px; }
var months = [{ id: 1, name: "January" }, { id: 2, name: "February" }, { id: 3, name: "March" }, { id: 4, name: "April" }, { id: 5, name: "May" }, { id: 6, name: "June" }, { id: 7, name: "July" }, { id: 8, name: "August" }, { id: 9, name: "September" }, { id: 10, name: "October" }, { id: 11, name: "November" }, { id: 12, name: "December" }];