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.
Unfortunately, activation email could not send to your email. Please try again.

Downloading Image of a chart

Thread ID:





124699 Jun 23,2016 05:29 AM Jul 7,2016 12:35 AM JavaScript 3
Tags: ejChart
Asked On June 23, 2016 05:29 AM

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);  
                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 03:33 AM

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. 
Saravana Kumar K. 

Replied On July 6, 2016 06:14 AM

Thank you, it worked!

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

Hi Andrei, 
Thanks for your update. 
Saravana Kumar K 


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.

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.