Vue Chart - JSON Data

To bind the Chart to data in a JSON format, assign the data's URL to the dataSource property.

App.vue
  • <template>
  • <DxChart data-source="http://www.example.com/dataservices/data.json">
  • <!-- ... -->
  • </DxChart>
  • </template>
  •  
  • <script>
  • import DxChart from 'devextreme-vue/chart';
  •  
  • export default {
  • components: {
  • DxChart
  • },
  • data() {
  • return {
  • // ...
  • }
  • }
  • }
  • </script>

Note that you can also use a JSONP callback parameter supported by jQuery.ajax().

App.vue
  • <template>
  • <DxChart data-source="http://www.example.com/dataservices/jsonpdata?callback=?">
  • <!-- ... -->
  • </DxChart>
  • </template>
  •  
  • <script>
  • import DxChart from 'devextreme-vue/chart';
  •  
  • export default {
  • components: {
  • DxChart
  • },
  • data() {
  • return {
  • // ...
  • }
  • }
  • }
  • </script>

If you need to process data after obtaining it, implement the CustomStore. For details, see the Custom Sources topic.

View Demo

See Also