How can I save HighCharts image into the project folder in PHP?

爱⌒轻易说出口 提交于 2019-12-12 02:05:26

问题


Im using highcharts to display some results, but i need to save the chart as an jpg image into the project folder to email it.

There is a way to save the image without involve the "download" of the browser, just save it to a destinated folder. Thanks.


回答1:


If you create your own export server like what is described here (I use the Java + phantomJS setup). You can then send via the command line the json to build the chart and the output type (jpeg, pdf, etc) and then you can redirect this output to a folder of your choice. You cannot do this from the web automagically as the code does not know your path to the folder you want to store the image in. For that see here.




回答2:


This is absolutely possible. The source code for the server-side export processing is available here:

https://github.com/highslide-software/highcharts.com/blob/master/exporting-server/php/php-batik/index.php

It's essentially getting a java program called Batik to stream out a PNG, JPG or PDF version of the file that you submitted. You could very easily modify that PHP code to save the batik output to a local file on the server rather than streaming it back to the user.

More info on exactly how the server-side exporting works is here:

http://www.highcharts.com/docs/export-module/export-module-overview

Hope this helps! Enjoy!



来源:https://stackoverflow.com/questions/26166403/how-can-i-save-highcharts-image-into-the-project-folder-in-php

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!