All docs
V21.1
24.2
The page you are viewing does not exist in version 24.2.
24.1
The page you are viewing does not exist in version 24.1.
23.2
The page you are viewing does not exist in version 23.2.
23.1
The page you are viewing does not exist in version 23.1.
22.2
The page you are viewing does not exist in version 22.2.
22.1
The page you are viewing does not exist in version 22.1.
21.2
21.1
20.2
20.1
19.2
The page you are viewing does not exist in version 19.2.
19.1
The page you are viewing does not exist in version 19.1.
18.2
The page you are viewing does not exist in version 18.2.
18.1
The page you are viewing does not exist in version 18.1.
17.2
The page you are viewing does not exist in version 17.2.
A newer version of this page is available. Switch to the current version.

JavaScript/jQuery Chart - OData Service

To bind the Chart to data provided by an OData service, use the ODataStore.

jQuery
index.js
$(function() {
    $("#chartContainer").dxChart({
        dataSource: new DevExpress.data.DataSource({
            store: {
                type: 'odata',
                url: 'https://www.example.com/dataservices/odata/targetData',
                key: 'Id'
            },
            paginate: false
        }),
        // ...
    });
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-chart [dataSource]="chartDataSource">
    <!-- ... -->
</dx-chart>
import { Component } from '@angular/core';
import 'devextreme/data/odata/store';
import DataSource from 'devextreme/data/data_source';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    chartDataSource = new DataSource({
        store: {
            type: 'odata',
            url: 'https://www.example.com/dataservices/odata/targetData',
            key: 'Id'
        },
        paginate: false
    });
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { DxChartModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxChartModule
    ],
    providers: [ ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxChart :data-source="chartDataSource">
        <!-- ... -->
    </DxChart>
</template>

<script>
import DxChart from 'devextreme-vue/chart';
import 'devextreme/data/odata/store';
import DataSource from 'devextreme/data/data_source';

const chartDataSource = new DataSource({
    store: {
        type: 'odata',
        url: 'https://www.example.com/dataservices/odata/targetData',
        key: 'Id'
    },
    paginate: false
});

export default {
    components: {
        DxChart
    },
    data() {
        return {
            chartDataSource
        }
    }
}
</script>
React
App.js
import Chart from 'devextreme-react/chart';
import 'devextreme/data/odata/store';
import DataSource from 'devextreme/data/data_source';

const chartDataSource = new DataSource({
    store: {
        type: 'odata',
        url: 'https://www.example.com/dataservices/odata/targetData',
        key: 'Id'
    },
    paginate: false
});

export default function App() {
    return (
        <Chart dataSource={chartDataSource}>
            {/* ... */}
        </Chart>
    );
}

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.

jQuery
index.js
$(function() {
    $("#chartContainer").dxChart({
        dataSource: new DevExpress.data.DataSource({
            store: {
                type: 'odata',
                url: 'https://www.example.com/dataservices/odata/targetData',
                key: 'Id'
            },
            paginate: false,
            // Take summer months only
            filter: [
                ['Id', '>=', 6],
                ['Id', '<=', 8]
            ]
        }),
        // ...
    });
});
Angular
app.component.html
app.component.ts
app.module.ts
<dx-chart [dataSource]="chartDataSource">
    <!-- ... -->
</dx-chart>
import { Component } from '@angular/core';
import 'devextreme/data/odata/store';
import DataSource from 'devextreme/data/data_source';

@Component({
    selector: 'app-root',
    templateUrl: './app.component.html',
    styleUrls: ['./app.component.css']
})
export class AppComponent {
    chartDataSource = new DataSource({
        store: {
            type: 'odata',
            url: 'https://www.example.com/dataservices/odata/targetData',
            key: 'Id'
        },
        paginate: false,
        // Take summer months only
        filter: [
            ['Id', '>=', 6],
            ['Id', '<=', 8]
        ]
    });
}
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';

import { DxChartModule } from 'devextreme-angular';

@NgModule({
    declarations: [
        AppComponent
    ],
    imports: [
        BrowserModule,
        DxChartModule
    ],
    providers: [ ],
    bootstrap: [AppComponent]
})
export class AppModule { }
Vue
App.vue
<template>
    <DxChart :data-source="chartDataSource">
        <!-- ... -->
    </DxChart>
</template>

<script>
import DxChart from 'devextreme-vue/chart';
import 'devextreme/data/odata/store';
import DataSource from 'devextreme/data/data_source';

const chartDataSource = new DataSource({
    store: {
        type: 'odata',
        url: 'https://www.example.com/dataservices/odata/targetData',
        key: 'Id'
    },
    paginate: false,
    // Take summer months only
    filter: [
        ['Id', '>=', 6],
        ['Id', '<=', 8]
    ]
});

export default {
    components: {
        DxChart
    },
    data() {
        return {
            chartDataSource
        }
    }
}
</script>
React
App.js
import Chart from 'devextreme-react/chart';
import 'devextreme/data/odata/store';
import DataSource from 'devextreme/data/data_source';

const chartDataSource = new DataSource({
    store: {
        type: 'odata',
        url: 'https://www.example.com/dataservices/odata/targetData',
        key: 'Id'
    },
    paginate: false,
    // Take summer months only
    filter: [
        ['Id', '>=', 6],
        ['Id', '<=', 8]
    ]
});

export default function App() {
    return (
        <Chart dataSource={chartDataSource}>
            {/* ... */}
        </Chart>
    );
}

View Demo

See Also