var obj = document.getElementById("chartId"); var myChart = echarts.init(obj);// $obj为原生dom对象 myChart.getDataURL({ type: 'jpeg', //png | jpeg pixelRatio: 2, backgroundColor: '#fff' //背景色白色 });获取 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();