Vue Chart - Access a Series Using the API

The Chart exposes the following methods for accessing a series. All of them return one or several objects whose fields and methods are described in the Series section of the API reference.

  • getAllSeries()
    Gets all series of the Chart.

    App.vue
    • <template>
    • <DxChart ref="chart">
    • </DxChart>
    • </template>
    •  
    • <script>
    • import DxChart from 'devextreme-vue/chart';
    •  
    • export default {
    • components: {
    • DxChart
    • },
    • methods: {
    • getAllSeries () {
    • return this.$refs.chart.instance.getAllSeries();
    • }
    • }
    • }
    • </script>
  • getSeriesByName(seriesName)
    Gets a series by its name.

    App.vue
    • <template>
    • <DxChart ref="chart">
    • </DxChart>
    • </template>
    •  
    • <script>
    • import DxChart from 'devextreme-vue/chart';
    •  
    • export default {
    • components: {
    • DxChart
    • },
    • methods: {
    • getSeriesByName (seriesName) {
    • return this.$refs.chart.instance.getSeriesByName(seriesName);
    • }
    • }
    • }
    • </script>
  • getSeriesByPos(seriesIndex)
    Gets a series by its index in the series array. The index is zero-based.

    App.vue
    • <template>
    • <DxChart ref="chart">
    • </DxChart>
    • </template>
    •  
    • <script>
    • import DxChart from 'devextreme-vue/chart';
    •  
    • export default {
    • components: {
    • DxChart
    • },
    • methods: {
    • getSeriesByPos(seriesIndex) {
    • return this.$refs.chart.instance.getSeriesByPos(seriesIndex);
    • }
    • }
    • }
    • </script>

Apart from the API methods, you can access a series in the event handlers. For example, the onSeriesClick event handler gets the clicked series in the argument.

App.vue
  • <template>
  • <DxChart @series-click="onSeriesClick">
  • </DxChart>
  • </template>
  •  
  • <script>
  • import DxChart from 'devextreme-vue/chart';
  •  
  • export default {
  • components: {
  • DxChart
  • },
  • methods: {
  • onSeriesClick (e) {
  • const series = e.target;
  • // ...
  • }
  • }
  • }
  • </script>

Once you get the series, you can access its child points. For further information, refer to the Access a Series Point Using the API topic.

See Also