- 下载
canvg.js
我的百度网盘js工具有如有需要请咨询
- 导入文件
<script src="../zui/lib/jquery/jquery.js"></script>
<script src="Highcharts-6.1.0/code/highstock.js"></script>
<script src="Highcharts-6.1.0/code/modules/exporting.js"></script>
<script src="Highcharts-6.1.0/code/modules/export-data.js"></script>
<script src="../zui/js/canvg.js"></script>
- 在html中加入一个canvas画布div
<canvas id='canvasId' style='display: none'></canvas>
- 在js中加入以下代码
var charData = $('#container_1').highcharts().getSVG();
canvg(canvasId, charData);
canvg(canvasId, charData);
function convertCanvas(canvas) {
var image = new Image();
image.src = canvas.toDataURL("image/png");
console.log(image)
return image
}
var imageData = convertCanvas(canvasId).src // 生成了base64编码
console.log(imageData)
imgAjax(imageData) // 发送ajax