Save a chart to physical path

TeeChart for JavaScript for the HTML5 Canvas
Post Reply
SenSeo
Newbie
Newbie
Posts: 71
Joined: Wed Mar 09, 2016 12:00 am

Save a chart to physical path

Post by SenSeo » Thu Apr 21, 2016 10:58 pm

I am able to create an image from generated chart using the below method.But I want to save the same image to physical location of the server path.

Chart1.draw();
Chart1.toImage('pngimage', 'image/png');
Chart1.toImage('jpgimage', 'image/jpeg');

How I can save the same image to server/any physical location?

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Save a chart to physical path

Post by Yeray » Fri Apr 22, 2016 11:36 am

Hello,

As far as I know the browser doesn't have direct access to filesystem. However, you can allow to download the png/jpg adding this to the javascript:

Code: Select all

  var imageLink = document.getElementById('imageLink');
  imageLink.href = Chart1.canvas.toDataURL('image/png');
and this to the html section:

Code: Select all

<a id="imageLink" download="myFilename.png">
    Click to download
</a>
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply