Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaScript AmChart to Image for Email

I have a couple of reports that generate JavaScript AmCharts off MySQL data (server-side language is PHP). Currently I need to email some of these reports on a weekly basis, and at the moment I just screen-print the charts to save as an image and embed it into a HTML email to send it.

A lot of the reports that don't require JavaScript I have automated to email by a weekly batch process (crontask). Is there anyway that AmCharts can generate an image file of a graph to be embedded into a report without intervention?

I have found a few different options for saving images from an AmChart but all of them require me to actually save the file away which is no better really then what I am doing now.

The charts themselves are simply Pie, Column and Line charts. Nothing fancy.

The real question is:

Can you generate an image file of an AmChart graph when the DOM is generated on the server side?

like image 489
elzaer Avatar asked Jul 15 '26 13:07

elzaer


1 Answers

you could handle that with PhantomJS

  • create a phantomjs script which opens your report and saves a screenshot of it
  • write some php to trigger that phantomjs script to add that to your cronjob
  • take the generated image to send that to your email recipients
like image 65
Maertz Avatar answered Jul 17 '26 21:07

Maertz