Generate Google Charts images using CRON and add to PDF - javascript

I want to be able to generate a Google Charts images and this will
done by cron job.
To start with, I understand that Google Charts is a client-side library that runs in browsers, so you can only generate charts in the browser. And also, I'm using a PHP Framework.
Here's where I am right now:
Firstly, I finished creating the PDF. Using MPDF, I was able to
successfully make a daily report in PDF format via cron.
Secondly, I already have generated server-side Google charts as images via the browser, and save those images to a folder. I was able to insert the image of the graph I wanted to
add.
https://developers.google.com/chart/interactive/docs/printing
But what I want is the cron job to generated the chart image. Setting the CRON, I'd like to generate an image of the certain Google Chart.
This is the closest topic I can find that is related to my question, but this thread didn't have an answer: Using Google Charts API Generated Graphic in FPDF

Related

Chart is not working on offline

I need a multi screen chart on html5 in offline. I used Google Chart and that was perfect, but It's could not work offline for their terms of service but I need Chart in offline.
Please watch the attached file.
Please watch this attached image . I need that type chart in offline.
So tell me how do I fix that problem.
You can do it by downloading required JS file locally and use them to generate chart for example, for D3.js all you need to do is download d3.js file and use code shown in link to generate chart.
Most of the chart library will work if you download relative js file and use those downloaded js file path instead using CDNs.
https://bl.ocks.org/mbostock/3887051

Rendering client side charts on the server

The product I'm working on has some nice graphs on a HTML5 dashboard. The graphs are rendered in Javascript using Flot.
Users would like this Dashboard emailed to them daily as a PDF report, on a fixed schedule. So for example they want an email every day at 8am to be emailed to them.
I've thought of using Python's Requests (i.e. do a request.get) to get the HTML5 source of the page and then convert the resulting HTML5 page to PDF using Weasyprint but this is obviously not going to work.
The Javascript charts are the biggest headache as they won't render unless viewed in a browser that has decent Javascript support, so the outlined approach won't render the Javascript graphs.
What's the recommended way of converting a dynamically generated HTML5 page into PDF? How do other people do this?
PhantomJS is the solution. It's a headless WebKit implementation that allows us to render to PDF the dashboards with Javascript graphs and all.
I've now set up a batch job that will run every day to convert our dashboards to a PDF document that gets emailed to the users.
Addendum
Some other things to be aware off. In the current 2.1 build of PhantomJS, there is a bug that causes renders to PDF to clip. The fix is scheduled for 2.2. A temporary workaround as detailed on the bug report is to set the CSS zoom level of the document. The following CSS fragment works for me.
html {
zoom: 50%;
}

Get images from Highcharts PHP Laravel

Good day, folks.
I am making something like CRM in Laravel, where users can see graphs and other cool stuff by Highcharts (based on their statistics). I also want to send them statistics each month in PDF (on email).
https://github.com/barryvdh/laravel-snappy is great at making PDF.
However, then comes the problem: I want to include images from Highcharts to these PDF's. But Highcharts is a JS library. And it really provides function for exporting images from graphs.
So really the question is: 'How can I (inside Laravel/PHP) get images, which are created by JS?'
Maybe I must run also JS server like Node.js (I don't know, haven't experience with it) and somehow get images from it?
You will need to save your images generated by Highcharts with the export module (http://www.highcharts.com/docs/export-module/export-module-overview).
Once the image is saved in the server, then you can access them using PHP.
I hope it helps you!

Processing Javascript on the server

I'm looking to use this chart generation library: http://www.jqchart.com/
Ideally, I would prefer to use a PHP charting library for the current project I'm working, but, by the looks of it, this is the only library I've found that can handle what I need to do (given a somewhat unconventional requirement for the charts).
The issue is that I need to get the generated graphs as images (at the moment each graph seems to be a combination of images) to the server so that I can generate some PDF documents, etc.
I'm thinking of attempting to create an image using JS, pushing this back to the server and then generating the PDF although this pretty nasty and will probably cause issues between different versions of the browser.
So now what I'm looking for is a solution that will allow me to generate the graphs and turn them into images on the backend.
Any ideas?
EDIT: For the requirement that led me to rule out a number of other charting libraries, see here: Complex charts in Google Charts
That really isn't all that relevant to the question of processing Javascript on the server, though.
You can render a javascript graph on the server using phantomjs. Here is an example.
Not sure what your requirements are, but I'd check out Google Chart Tools: http://code.google.com/apis/chart/. It's really simple to use. All the data is in the image URL get request, so you can generate charts using client-side JavaScript too.

Run Flot, Javascript on Server?

I would like to use a Javascript library (Flot) to generate charts in my application. Most of the time, the charting will be performed by clients. However, I can see that in some cases, where the same charts would be frequently accessed by all clients, it would be better to generate those charts on the server, cache them, and serve them as images.
How could I go about executing Javascript from a script that runs on the server? Can Flot be used to generate PNG's?
This should be possible with Node.js and node-canvas. Node-Canvas can spit out PNGs for your cached graphs.

Categories