Chartjs-Show 'No data' in Pie when there is no data using VueJS and ChartJS?

0๐Ÿ‘

I need full version of your .vue file, but I tried write roughly ..

<div class="wrapper mt-5">
   <canvas v-if="hasData" ref="myChart2" id="myChart2" width="600" height="250" class="mb-5"></canvas>
   <span v-else >No data</span>
 </div>
data(){
  return {
    chartType: '', // if user select something, bind this
    best_beneficiaries: []
  }
},

computed: {
  hasData: function() {
    return !!this.best_beneficiaries && !!this.chartType;
  }
},

methods: {
  getData: function() {
    // your METHOD will be here, and set this.best_beneficiaries 
  }
}

Leave a comment