I recently came into contact with highcharts and found that this thing is a bit cool, but I encountered a problem. How to save the image generated by highcharts to the local computer? Or how to put the generated image into PDF? I hope you all will give me some advice, thank you very much.
I recently came into contact with highcharts and found that this thing is a bit cool, but I encountered a problem. How to save the image generated by highcharts to the local computer? Or how to put the generated image into PDF? I hope you all will give me some advice, thank you very much.
highcharts is implemented based on canvas.
canvas has a toDataURL method to get the image data path.
The pseudocode I used is just for illustration
<code>data路径 = $("#图表的canvas")[0].toDataURL("image/png")</code>
Save to local:
<code>1、<img src="data路径"> 提示用户另存即可 2、<a target="_blank" href="data路径">下载</a> 客户点击即可看到图片</code>
Save to server:
ajax upload data path, library; or save the image after decoding it with base64.