切换事假中清除echart
checkNav(e){ this.setData({ activeIndex: e.currentTarget.dataset.index, activeName: e.currentTarget.dataset.navname, }) tab1Echart.dispatchAction({ type: 'updateAxisPointer', currTrigger: 'leave' }) this.getNewRevenue() },
echarts代码
import * as echarts from '../../../ec-canvas/echarts'; let tab1Echart = null function lineOption(tab1Xdata, y1Data, y2Data,y3Data){ let option = { title: { text: tab1Xdata.length==0?'暂无数据':'', x: 'center' , y: 'center' , textStyle: { color: '#bcbcbc', fontWeight: 600, fontSize: 16 } }, legend: { selectedMode: false, // data: [tab1Line1Name, tab1Line2Name], top: '2%', left: 'left', backgroundColor: '#fff', z: 100, }, grid: { left: '3%',right: '3%',top: '20%',bottom: '3%', containLabel: true }, tooltip: { show: true, trigger: 'shadow', axisPointer:{ shadowStyle:{ color: 'rgba(150,150,150,0.3)' } } }, xAxis: { type: 'category', boundaryGap: false, data: tab1Xdata, }, yAxis: { type: 'value', x: 'center', splitLine: { lineStyle: { type: 'dashed' } }, }, series: [] }; return option } let xData = [], onedata = [],twodata = [], beonline = [] function initChart(canvas, width, height) { tab1Echart = echarts.init(canvas, null, { width, height: height }); canvas.setChart(tab1Echart); // tab1Echart.showLoading({ // text: 'loading', // color: '#c23531', // textColor: '#000', // maskColor: 'rgba(255, 255, 255, 0.2)', // zlevel: 0, // }); var option = lineOption(xData, onedata, twodata, beonline) tab1Echart.setOption(option); return tab1Echart; }