Save to a PNG image when I'm using a pattern fill

Share RGraph:   Share or Like RGraph on Facebook!

« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by Berjawi on 18th November 2016
First I would like to thank you for this great work.
I have a question; it is possible to save a chart as PNG when using a pattern instead of color?

I looked at these:

but it does not work when I combine both.

Any help will be appreciated.
Posted by Richard on 18th November 2016
Hi there,

Seems to work fine. For example I added this:

<a href="javascript: location.href = line.canvas.toDataURL()">Get PNG</a>

to the page (with the patterned fill) and it shows an image of the chart. If you want to save that as a file you'll need to (using jQuery perhaps) send it to the server (if you use jquery the $.post() function will come in useful) where a server side script can save it to a file. There's more info about saving the chart to a file here:

There's also a sample PHP script on that page that saves the data to a file.

Posted by Berjawi on 21st November 2016
Can you please check this:,css,js,output

if I remove the pattern, the code works fine;
Posted by Richard on 21st November 2016
Hi there,

You're loading an image from a different domain which effectively disables the export to PNG functionality of canvas for security reasons.


Add a reply

« Back to message list