echarts-vue

新建一个div用作显示图表

image-20211113164755743

用于画图的方法 id 是挂载的div id


setEcharsPie(id, data, xData) {
      // 基于准备好的dom,初始化echarts实例
      const myChart = echarts.init(document.getElementById(id))
      // 绘制图表
      var option
      option = {
        title: {
          text: this.mont + '月事故分析图表'
        },
        tooltip: {
          trigger: 'item',
          axisPointer: {
            type: 'shadow'
          }
        },
        legend: { right: '10%', top: '2%', data: xData },
        label: {
          formatter: '{b}:{@2012} ({d}%)'
        },
        series: [
          {
            name: '任务统计',
            type: 'pie',
            radius: '60%',
            center: ['50%', '50%'],
            data
          }
        ]
      }
      myChart.setOption(option, true)
    },
posted @ 2021-11-13 17:03  李广龙  阅读(49)  评论(0)    收藏  举报