Page 1 of 1

Save a chart to physical path

Posted: Thu Apr 21, 2016 10:58 pm
by 15677821
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?

Re: Save a chart to physical path

Posted: Fri Apr 22, 2016 11:36 am
by yeray
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>