// @ts-ignore import * as echarts from '../../../../../../components/ec-canvas/echarts.js' import {PeopleChart1,getPeopleChart2} from '../../../../utils/echarts' Component({ /** * 组件的属性列表 */ properties: { }, /** * 组件的初始数据 */ data: { ecA: { lazyLoad: true }, ecB: { lazyLoad: true }, colorData: ["#FFC600", "#29B9A5"], chartsData:[{ name: '好好', value: '20' }, { name: '好', value: '30' }], colorData2:['#AD6DFE', '#FFA270'], chartsData2: [{ name: '好好', value: '20' }, { name: '好', value: '30' }] }, lifetimes: { attached() { // @ts-ignore this.ecComponentA = this.selectComponent('#mychart-dom-bar') // @ts-ignore this.ecComponentB = this.selectComponent('#mychart-dom-pie') this.initA() this.initB() } }, methods: { // 点击按钮后初始化图表 initA () { // @ts-ignore this.ecComponentA.init((canvas: any, width: any, height: any) => { const chart = echarts.init(canvas, null, { width: width, height: height }) PeopleChart1(chart,this.data.colorData,this.data.chartsData) return chart }) }, initB () { // @ts-ignore this.ecComponentB.init((canvas: any, width: any, height: any) => { const chart = echarts.init(canvas, null, { width: width, height: height }) getPeopleChart2(chart,this.data.colorData2,this.data.chartsData2) return chart }) }, } })