Home Forums Chart Support How to display chart as a static image (png, jpg) Reply To: How to display chart as a static image (png, jpg)

#15997

@davidr.

You can get base64 image data of a canvas by using toDataURL. As CanvasJS charts are rendered on canvas, you can use toDataURL on chart to get base64 image data of the chart. Passing base64 data as source of image should work fine in your case. Please find the code-snippet below

var base64Image = chart.canvas.toDataURL();
document.getElementById('chartContainer').style.display = 'none';
document.getElementById('chartImage').src = base64Image;

Please check this JSFiddle for an example on the same.

exporting chart as base64 image


Vishwas R
Team CanvasJS