安裝:
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
簡單易懂直接收集看吧
.