[Vuejs]-Vue ChartJS get data from a chart in component

0👍

Indeed it was obvious.

just need a ref attribute in my chart.

<Bar v-if="!is_loading"
    :chart-options="chartOptions"
    :chart-data="chartData"
    :chart-id="chartId"
    :dataset-id-key="datasetIdKey"
    :plugins="plugins"
    :css-classes="cssClasses"
    :styles="styles"
    :width="width"
    :height="height"
    ref="myBarChart"
/>

and in the method:

handleChartClick(e){
   var chart = this.$refs.myBarChart.$data._chart;
}

Leave a comment