#echarts chart generation Base64 method
First find the chart hosting container
For example
<div style="height: 100%;width:100%" id="fixed"></div>
I encapsulated a method of converting to base64:
/*
echarts图转base64
ele 图表DOM 容器ID 对应例子的ID("#fixed")
*/
function createBase64(ele) {
let docEle = ele + " canvas";
let canvasFixed = document.querySelector(docEle),//获取图表元素
canvasWidth = canvasFixed.width,//获取图表元素宽度
canvasHeigth = canvasFixed.heigth,//获取图表元素高度
canvas2D = canvasFixed.getContext('2d');
canvas2D.drawImage(canvasFixed,canvasWidth,canvasHeigth);
return canvasFixed.toDataURL()
}
let echartsBase64 = createBase64("#fixed");
console.log(echartsBase64)
The effect is shown in the figure:
)(https://imgtu.com/i/4FdKij#pic_center)]
After copying it, you can put it in the browser or parse the base64 website to check whether it is ok:
Once you get it, you can do what you want to do;