1.在项目根目录下cmd执行
npm install echarts --sav
2.在main.js中引用
// 引入echarts
import * as echarts from 'echarts'
Vue.prototype.$echarts = echarts
3.页面
<view id="myChart" :style="{width: echertWidth, height: sHeight}"></view>
mounted() {
this.drawLine();
},
drawLine() {
// 基于准备好的dom,初始化echarts实例
let myChart = this.$echarts.init(document.getElementById('myChart'))
// 绘制图表
myChart.setOption({
tooltip: {},
xAxis: {
data: ['9.11', '9.12', '9.13', '9.14'],
axisLabel: {
show: true,
textStyle: {
color: '#ffffff'
}
}
},
yAxis: {
type: 'value',
axisTick: {
show: false
},
splitLine: {
show: false
},
splitNumber: 2,
axisLabel: {
textStyle: {
color: '#ffffff'
}
}
},
series: [{
type: 'bar',
data: [5, 20, 36, 10, 10, 20],
barWidth: 10,
itemStyle: {
normal: {
color: '#00C1F8'
}
},
}],
});
},