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. Image for the cookie policy date

Downloading Image of a chart

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.



3 Replies

SK Saravana Kumar Kanagavel Syncfusion Team 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. 



AN andrei July 6, 2016 10:14 AM UTC

Thank you, it worked!


SK Saravana Kumar Kanagavel Syncfusion Team July 7, 2016 04:35 AM UTC

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


Loader.
Up arrow icon