We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Downloading Image of a chart

Thread ID:

Created:

Updated:

Platform:

Replies:

124699 Jun 23,2016 09:29 AM UTC Jul 7,2016 04:35 AM UTC JavaScript 3
loading
Tags: ejChart
andrei
Asked On June 23, 2016 09:29 AM UTC

Hi,
I'm getting an error while I'm trying to download a image of my chart , this is my JS:
    function download() {
        var type = this.id;
        type = "png"
        var chart = $("#chartcontainer").ejChart("instance"),
            exporting = chart.model.exportSettings,
            data, type;
        exporting.fileName = "img";
        exporting.angle = 0;
        exporting.type = type;
        exporting.mode = "Client";
        data = chart.export();
        this.download = exporting.fileName + "." + type;
        if (type == "png") this.rel='nofollow' href = data.toDataURL();
    }
    clientPng = document.getElementById('download');
    if (clientPng.addEventListener)
                clientPng.addEventListener('click', download, false);  
    else
                clientPng.attachEvent('onclick', download, false); 

And this is the error:
ej.web.all.min.js:10 Uncaught TypeError: Failed to execute 'drawImage' on 'CanvasRenderingContext2D': The provided value is not of type '(HTMLImageElement or HTMLVideoElement or HTMLCanvasElement or ImageBitmap)'

Thank you.



Saravana Kumar Kanagavel [Syncfusion]
Replied On June 24, 2016 07:33 AM UTC

Hi Andrei, 
 
Thanks for contacting Syncfusion Support. 
We have analyzed your query. Reported exception will occur only if chart rendering in svg mode. So ensure the “enableCanvasRendering” as true in your sample to export the chart as “png” image and which property of default value as false. And also we would like to inform that the chart exporting as images can be possible only by canvas mode.  
 
And we have also made a chart exporting as image sample for your reference and attached in the below location. 
 
  
Please let us know if you have any concern. 
 
Regards, 
Saravana Kumar K. 


andrei
Replied On July 6, 2016 10:14 AM UTC

Thank you, it worked!

Saravana Kumar Kanagavel [Syncfusion]
Replied On July 7, 2016 04:35 AM UTC

Hi Andrei, 
  
Thanks for your update. 
  
Regards, 
Saravana Kumar K 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;