Chart.js 清除数据 和 line(曲线改为直线)

vue





import "../../../js/Chart"


if (this.el_chart) {
//如果之前有数据 重新获取数据 鼠标移入canvas 会出现前后数据晃动 ************
  this.el_chart.destroy();   
}
let ctx = this.$refs.popChart.getContext('2d');
let options = {
  type: 'line', //'radar',//'line',//'pie',//'bar',//doughnut  
  data: {
    labels: data.sale_date_list,
    datasets: [{
      label: '总销售额',
      data: data.sun_amount_list,
      backgroundColor: 'rgba(252,93,93,0.2)',
      borderColor: '#FC5D5D',
      tension:0, ////张力,0为没曲线  成为直线            *******************
    },
      {
        label: '线上销售额',
        data: data.online_amount_list,
        backgroundColor: 'rgba(113,149,250,0.2)',
        borderColor: '#7195FA',
        tension:0
      },
      {
        label: '线下销售额',
        data: data.shop_amount_list,
        backgroundColor: 'rgba(93,255,111,0.2)',
        borderColor: '#52FC6C',
        tension:0, ////张力,0为没曲线
      },
    ]
}
}
this.el_chart = new Chart(ctx,options);

 

你可能感兴趣的:(vue,chartJs)