javascript - Please tell me how to save the pie chart displayed in html by highcharts locally without using the built-in exporting function.

WBOY
Release: 2016-08-27 09:06:49
Original
1113 people have browsed it

javascript - Please tell me how to save the pie chart displayed in html by highcharts locally without using the built-in exporting function.

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.

Reply content:

javascript - Please tell me how to save the pie chart displayed in html by highcharts locally without using the built-in exporting function.

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>
Copy after login

Save to local:

<code>1、<img src="data路径"> 提示用户另存即可
2、<a target="_blank" href="data路径">下载</a> 客户点击即可看到图片</code>
Copy after login

Save to server:
ajax upload data path, library; or save the image after decoding it with base64.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template