const app = getApp(); import * as echarts from '../../../../ec-canvas/echarts' // 这个是自己实际的目录 Component({ data:{ Ec: { lazyLoad: true, }, }, lifetimes: { attached: function () { this.init() }, moved: function () { }, detached: function () { }, }, methods:{ init(){ var that = this; that.selectComponent('#chartConDom').init((canvas, width, height, dpr) => { const chart = echarts.init(canvas, null, { width: width, height: height, devicePixelRatio: dpr }); var option = that.getOrderWarnOption(); chart.setOption(option); return chart; }); }, getOrderWarnOption(){ var list = [{name:"追溯产品",value:999,},{name:"非追溯产品",value:666,},] var fontSize = 10 var fontColor = "#999999" return { color:["#7A4AFF","#FFAE36"], legend:{ icon:"circle", itemWidth:fontSize*0.8, itemHeight:fontSize*0.8, textStyle:{ fontSize:fontSize*0.9, color:fontColor, }, data:list.map(item=>item.name) }, series:[ { type: 'pie', silent:1, radius:'75%', center: ["50%", '55%'], label:{ show:true, formatter:"{c}", fontSize:10, position:"inside", color:'#ffffff', }, data: list, }, ] } }, }, })