vue项目中安装使用echarts

安装:
cnpm install echarts -S (安装依赖并引入到 package.json)

官网安装说明:http://echarts.baidu.com/tutorial.html#%E5%9C%A8%20webpack%20%E4%B8%AD%E4%BD%BF%E7%94%A8%20ECharts 

按需引入,以加快打开速度:

按需引入的模块列表见 https://github.com/ecomfe/echarts/blob/master/index.js

// 引入基本模板
let echarts = require('echarts/lib/echarts')
// 引入柱状图组件
require('echarts/lib/chart/bar')
// 引入提示框和title组件
require('echarts/lib/component/tooltip')
require('echarts/lib/component/title')
export default {
  name: 'hello',
  data() {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
  mounted() {
    var drawLine = this.drawLine();
window.onresize = function temp() {
drawLine.resize(); //重绘,窗口大小改动时
};
  },
  methods: {
    drawLine() {
      // 基于准备好的dom,初始化echarts实例
      let myChart = echarts.init(document.getElementById('myChart'))
      // 绘制图表
      myChart.setOption({
        title: { text: 'ECharts 入门示例' },
        tooltip: {},
        xAxis: {
          data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"]
        },
        yAxis: {},
        series: [{
          name: '销量',
          type: 'bar',
          data: [5, 20, 36, 10, 10, 20]
        }]
      });
    return
myChart;

} } }

这里参考

百度ECHARTS官网及文档:http://echarts.baidu.com/

参考:http://blog.csdn.net/mr_wuch/article/details/70225364

简单易懂直接收集看吧

.

原文地址:https://www.cnblogs.com/xiangsj/p/7249887.html