JavaScript/jQuery Chart - OData Service
To bind the Chart to data provided by an OData service, use the ODataStore.
JavaScript
- $(function() {
- $("#chartContainer").dxChart({
- dataSource: new DevExpress.data.DataSource({
- store: {
- type: 'odata',
- url: 'https://js.devexpress.com/Demos/WidgetsGallery/odata/WeatherItems',
- key: 'Id'
- },
- paginate: false
- }),
- commonSeriesSettings: {
- argumentField: 'Name',
- type: 'bar'
- },
- series: [
- { valueField: 'RecordHigh', name: 'Highest temperature, °C' },
- { valueField: 'RecordLow', name: 'Lowest temperature, °C' },
- { valueField: 'Average', name: 'Average temperature, °C' }
- ]
- });
- });
As you may notice, in the previous code, the ODataStore is not declared explicilty. Instead, it is wrapped in the DataSource instance. That is because the Chart requires pagination to be off in order to prevent data from partitioning. Other than that, the DataSource provides wide data-processing capabilities. For example, it can filter data.
JavaScript
- $(function() {
- $("#chartContainer").dxChart({
- dataSource: new DevExpress.data.DataSource({
- store: {
- type: 'odata',
- url: 'https://js.devexpress.com/Demos/WidgetsGallery/odata/WeatherItems',
- key: 'Id'
- },
- paginate: false,
- // Takes the summer months only
- filter: [
- ['Id', '>=', 6],
- ['Id', '<=', 8]
- ]
- }),
- // ...
- // See the previous code for the series configuration
- });
- });
See Also
Feel free to share topic-related thoughts here.
If you have technical questions, please create a support ticket in the DevExpress Support Center.
Thank you for the feedback!
If you have technical questions, please create a support ticket in the DevExpress Support Center.