I have a node.js application that accesses data of a MySQL database and I want to generate charts from that data dynamically, to pipe it as image (PNG/JPG) through a HTTP server to the user. I've search for a little while now, but I was unable to find a library to do this without the HTML/canvas approach. Since I want to let the server do the rendering to use the graph in emails or also dynamically rendered PDF files, this isn't an option here.
What could be the approach here (with or without a library) ?
Edit to provide proof of own work: I found https://plot.ly, which is in terms of usage and result really close to fulfil my needs, but requires an internet connection, since it calls a remote API.
You could also try asking this in the Software Recs Stack Overflow. But one option that seems like it could fit your needs is ZingChart.
They have a phantomJS build for rendering static versions of charts. In addition, licensed users can access a Node.js build for server side charting.
Full disclosure, I'm on the ZingChart team so please let me know if I can help you review all your options.
There is a node wrapper for the chart library chartist. You could use this library to generate a SVG, and a svg2png lib to convert to PNG.
Well there are multiple options, I would use phantomjs (headless Webkit browser) to render the charts.
Why would this option be good? One of the reasons is that you don't need duplicated code for the server and client side coding, you could simply reuse the code. On server side create a html file with required scripts and data and render it.
Related
I need to render a PDF document in web browser (HTML5).
User should be able to make a selection for annotation (text or area).
Render html elements on the annotation (check-boxes, drop-down) received through ajax.
User's choice will be sent to back-end along with the selection/annotation made.
I should be able to render the annotations made again on the PDF.
Which frameworks should I use to create this solution? I'm happy to use open source frameworks as well as licensed SDKs. I can manage handling back-end using Node.js and interactions with ajax calls.
I did some research and found that I can use PDF.js for rendering PDF. Found many solutions to annonate but they cannot be used to render HTML elements on an annotation. I'm happy to get PSPDFKit but no way to create html elements on PDF.
I found two solutions and I'm really happy with them.
Annotate.co
PSPDFKit
Almost everything needed is there.
Why would you do such thing??: because in some particular cases I need to hide the source values of a graph generated by dygraph. Since in the case of "not hidden values" I am using dygraphs js libray, using this particular feature would save me a lot of time.
This way I would have the same look and feel, and I would not have to modify the data generation process.
I would like to know if this road is feasible or utter madness:
Steps: (using Yii-PHP over an Apache server)
Generate javascript page on the server side.
Get image as png (somehow), still on the server side.
Send the image to the client as the only thing he can receive.
There's a ton of graphing libraries for PHP, why not use one of those? (e.g. JpGraph, pChart...) Pretty much every one of them can produce an image in PNG.
Feasible steps:
Invoke a PHP graphing library on server side
Render it as PNG and send to the client
If you insist on using a JavaScript library, then I guess PhantomJS is your only option, but it is not exactly optimal.
tl;dr: My vote goes to "utter madness".
Some dygraphs users have built a tool for exporting PNGs: demo and discussion.
I'm working on a project that involves exporting some HTML reports on a website into PDF format. I'd like to use the excellent flying-saucer Java library to do this but my major stumbling block is that several of these reports use the Google Visualization API to generate charts with JavaScript. Flying-saucer doesn't currently support parsing/executing JS, so those charts don't show up in the generated PDF file.
I was hoping to work around this by seeing if there was some kind of web service I could call instead via server-side code that would return the chart image in Base64 as a variable that I could reference in my view instead of getting it via JS.
The old Google Image Charts API is exactly what I'm looking for, but it has unfortunately been deprecated and it looks like it's slated to be removed completely by next year, so it's not an option.
I'm hoping Google has a newer alternative. If not, is there some other method that's recommended? Thanks!
You can call the getImageURI method of the chart to generate an image/octet stream URI. You can send that data to your server, and you should be able to reconstruct the chart as a .png image file. I've never tried to do this server-side, so I'm not sure precisely how you would go about it, but this java tutorial might be of some assistance to you: http://www.programcreek.com/2009/02/java-convert-image-to-byte-array-convert-byte-array-to-image/
Years ago I wrote Eastwood Charts which implemented the Google Image Charts API as a servlet, backed by JFreeChart, so that you could generate charts without having to rely upon Google, or send your data to their servers. :-)
I don't maintain Eastwood Charts anymore (like Google, I can't be relied upon either) but it is open source and the code works so you might find it helpful. You could also modify it to meet your own requirements, which is something that wasn't possible with the Google service.
I want to create a computer network diagram dynamically on UI, with the network diagram having switches, routers and other devices and these devices are connected with links and i need to label these links at both ends of the devices being connected by a particular link.
I am open to creating this image from backend, I have python for backend, with any image creation library. Though i would still prefer if there is any way to do it with any JS module, if available. In python i came across one library PIL.
Could you please point me to any JS modules that can help me do this, or any python module which would best suite the requirement.
Thanks in advance.
You may want to take a look at the RaphaelJS Javascript library, which uses SVG under the covers. Their website have an example with a graph which may be a good starting point to your diagram creation code: http://raphaeljs.com/graffle.html That's what I'd recommend for doing it in the client side.
If you actually were to do in the backend with Python, you could look for a solution using GraphViz under the covers, maybe python-graph or pydot.
I have a HTML page that uses javascript to generate dynamic images using a graph handler on a different server. The images will contain the same data for 1 week but will change when the 1 week window expires.
I am trying to come up with a way to automatically save the contents of the page to either a local file on the server or write to a PDF file.
I tried to use a 'web downloader' like HTTTrack, but it does not get the dynamic images...
I am running the html page off IIS.
I have no experience with IIS or ASP.
Thanks!
I'm not sure that I see any way to do this directly off the front end in an automatic manner. The challenge is that any "screen scraper" you have go out and grab the site with would need to be running javascript to get the tables, which isn't how I see many such systems operating. It's partially why you see strangeness on Archive.org when you have a site that's heavily augmented with javascript or flash.
An untested concept you might attempt was posted in this Stack Question
I could see some sort of a system that you rig together with another computer that schedules an browser load then prints to .pdf in some fashion. I've been unable to find any specific software that would automate that process, so you'd be left cobbling such a system together on your own.
Clearly you have the data available to make your dynamic images. The most feature-rich way I could think of would be to use a system like Jasper Reports or Crystal Reports, which you could feed your data, replicate the report, and easily output via pdf, a built-in export in both systems.
Perhaps its worth questioning your end purpose. To me, creating a "snapshot" of the relevant data in another table and using another system to render your graphs from that snapshot data seems far more valuable than just a print of the screen. You can then go back and adjust data as needed, or use it for other reporting purposes, exporting in any number of tools that are even as simple as Access. Heck, 10 years down the road you may want the data to look better than the graph system you're currently using, and you'd have the data to render it any way you want. When the VP of marketing comes looking for his numbers, a simple click would output those numbers that could be manipulated as needed from there.
I was able to accomplish what I wanted to do using wkhtmltopdf to convert my HTML page with Javascript to PDF. I ran the job via a task scheduler to supply my website url and output file name as parameters.
I then used a windows batch file to check if the file was created and then rename/email it to interested parties.
This of course requires that you have the ability to install wkhtmltopdf on your server.