Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert jqplot chart to image

I'm trying to convert the entire jqplot bar chart, including it's legend and chart title, to image. However, using toDataURL and steps in this post (Convert canvas to image and open in new window using ruby on rails and javascript), I'm only able to convert the chart with it's axis and axis label to image.

As the legend and chart title is not rendered on the canvas, they are not being converted.

Can someone tell me how to convert the chart title and legend with the canvas please?

like image 379
Mich Avatar asked Jun 08 '11 09:06

Mich


2 Answers

Since the title and axes are div and not img or canvas I think the only solution would be to write every text in a canvas with the fillText() function. Then convert this to picture.

You can write in canvas like that : fillText("Hello World!", x, y);

Now you can also add this to jQplot as a plugin :)

Good luck

like image 133
Tim Avatar answered Nov 15 '22 00:11

Tim


I have been working on a bare implementation. It is linked here https://bitbucket.org/cleonello/jqplot/issue/14/export-capabilities#comment-554274 It should support every example that is distributed with jqplot.

like image 2
Kevin Risden Avatar answered Nov 15 '22 02:11

Kevin Risden