Vue Chart - OData Service
To bind the Chart to data provided by an OData service, use the ODataStore.
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>
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.
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>
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.