1.下载 GitHub 上的 ecomfe/echarts-for-weixin 项目
2.echarts下载,在线定制,选择图表,代码压缩
3.替换项目ec-canvas中的echarts.js
4.page.json引入
{ "usingComponents": { "ec-canvas":"../../../../ec-canvas/ec-canvas" } } 5.js中引入 import * as echarts from "../../../../ec-canvas/echarts" //初始化 init(arr){ this.lazyComponent.init((canvas,width,height,dpr)=>{ let chart=echarts.init(canvas,null,{ width:width,height:height,devicePixelRation:dpr }) let option=this.getOption(arr) chart.setOption(option) this.chart=chart return chart }) }, getOption(arr){ return{ xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
},
yAxis: {
type: 'value'
},
series: [
{
data: arr,
type: 'bar'
}
]