Vue項目中引入Echarts

 安裝Echats

npm install echarts --save

項目main.js中引入Echarts

// 引入Echarts
import Echarts from 'echarts'
Vue.prototype.echarts = Echarts
Vue.use(Echarts)
mounted() {
      var dom = document.getElementById('echarts')
      var myChart = this.echarts.init(dom)
      // 繪製圖表
      myChart.setOption({
        series: [{
          name: '訪問來源',
          type: 'pie',
          radius: '55%',
          data: [{
              value: 235,
              name: '視頻廣告'
            },
            {
              value: 274,
              name: '聯盟廣告'
            },
            {
              value: 310,
              name: '郵件營銷'
            },
            {
              value: 335,
              name: '直接訪問'
            },
            {
              value: 400,
              name: '搜索引擎'
            }
          ]
        }]
      });
    },

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章