Send FLOT chart in an email

I have a PHP app that is called via cron to run through some tasks and generate an email. I would like to use the FLOT charting library and include some charts in this email. How do I get the charts out since the php is called via cron?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
I think you might want to choose another strategy.  Email clients typically will not run JavaScript at all -- too much security exposure.  A better idea might be to put the FLOT JavaScript into a web page and send your clients a link to the web page.
DalexanAuthor Commented:
Is there a way to output the results to a file saving the chart as an image? I'm assuming since I'm running the php from the command line the JavaScript may not work?
Ray PaseurCommented:
output the results to a file...
Not that I am aware of.  This does not seem to fit the design of client/server protocols.  Let me try to explain the timeline that is in play here.

First, there is an HTTP request from a client to a server.  The client is usually a web browser, but it can be anything that originates the HTTP request, including the command line or even another server (think "screen scraper").  The main point here is that a server sits idle until it receives a request from the client.

Next, the server responds to the client request, using its own data model and anything that the client sent in the request (cookies, URL parameters. etc).  During the formulation of the response, servers typically create an HTML document, and send it along with CSS, JavaScript and data from the server.

Both the request and response are atomic, complete and usually instantaneous.  After the response is sent, the server disconnects and sits idle again, waiting for the next request.

When the client receives the response, it begins to process the HTML document, preparing the document object model (the software representation of the screen image), formatting the response according to the CSS, and running JavaScript.  It is at this point, after the server has disconnected, that the JavaScript begins to run.

There are ways for JavaScript to make requests to the server and send data (this is typically called AJAX) and there may be some ways for FLOT charts to send some data back to the server, but it would be a research project, and it "feels" like the wrong way to try this project.  My guess is that the data, dataset, and options you would use in the FLOT charts are created in the server and would be sent with the JavaScript as part of the server response.  So I am thinking that the division of labor here is not conducive to using FLOT for a client display in an email, or for recovering an image on the server.

PHP charting software that does not use JavaScript might be a better idea.  Here is some up-to-date research on the server-side charting software.  These libraries will generate image files that contain the charts.  Most email programs and all web browsers can render images correctly.

My experience with JpGraph leads me to believe it might be worth a try.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.