echarts获取图片base64字符串
var obj = document.getElementById("chartId");
var myChart = echarts.init(obj);// $obj为原生dom对象
myChart.getDataURL({
type: 'jpeg', //png | jpeg
pixelRatio: 2,
backgroundColor: '#fff' //背景色白色
});
官方文档:
https://www.echartsjs.com/en/api.html#echartsInstance.getDataURL
获取 canvas,导出图片
var echartCanvas = $("#echartId").find("canvas")[0];
var image = echartCanvas.toDataURL("image/jpeg");
var a = document.createElement('a');
a.setAttribute("href", image);
a.setAttribute("download", "图片名称");
a.click();
【Java面试题与答案】整理推荐