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

Share RGraph:   To help my Google visibility (it can't get much worse!), if you like and use RGraph I'd appreciate it if you could link to me

« 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
Hello,
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:
www.rgraph.net/docs/howto-use-repeating-fill-patterns-on-your-chart.html
and
www.rgraph.net/docs/retrieving-a-png-of-your-charts.html

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:

www.rgraph.net/docs/integration-with-server-side-scripting.html#image

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




Richard
Posted by Berjawi on 21st November 2016
Can you please check this:
jsbin.com/kixipa/edit?html,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.




Richard

Add a reply




« Back to message list