ec-echarts 循环canvasToTempFilePath 安卓机只执行一次?
ec-echarts 循环canvasToTempFilePath 安卓机只执行一次?
for (let i = 0; i < data.length; i++) {
let item = {
onInit: function (canvas, width, height) {
const barChart = echarts.init(canvas, null, {
width: width,
height: 450
});
canvas.setChart(barChart);
barChart.on('finished', () => {
console.log("finished")
let className = `.line${i}`
c.selectComponent(className).canvasToTempFilePath({
success: res => {
console.log(res)
console.log("imgs")
let echartsSrc = res.tempFilePath;
// c.setData({
// echartImgSrc: res.tempFilePath
// })
c.data.echartsImgList.push(echartsSrc);
if(c.data.echartsImgList.length>0){
c.data.showEcharts=false;
}
console.log(c.data.echartsImgList)
c.setData({
echartsImgList:c.data.echartsImgList,
showEcharts:c.data.showEcharts
});
wx.hideLoading();
},
fail: res => {console.log('转换图片失败', res);wx.hideLoading();}
});
});
barChart.setOption(c.getLineOption(canvas, data[i]));
return barChart;
}
};
c.data.ecList.push(item);
}