Hi Ankur
Thanks for using Syncfusion product.
We have analyzed this. The below are the steps to be followed to export a chart as image.
· Render the chart in HTML5 canvas. This is done by setting the below property
[ASPX] <ej:Chart ID="Chart1" runat="server" Width="970" Height="600" CanResize="true" EnableCanvasRendering="True"> </ej:Chart> |
· Add an image/button inside the anchor tag
[HTML] <a id="download" download="Chart.png" style="float: right; cursor: pointer;" > <img src="export.png" title="Export Chart" /> </a> |
· Code the chart as desire
· On clicking the anchor tag the below method got called
[JS] function download() { var canvas = $("#Chart1").ejChart("exportChart"); var dt = canvas.toDataURL(); this.rel='nofollow' href = dt; } document.getElementById('download').addEventListener('click', download, false); |
We have also made a sample to export the chart rendered as an image. Find it from the below location.
Please let us know if you have any concern.
Thanks,
Jayavigneshwaran
Hi Ankur,
Sorry for the inconvenienced caused.
We have analyzed this. This exception happens because that you are trying to add event to an element before it is appended to DOM.
So, this can be done after the load of DOM. The below code snippet does this.
[JS] window.addEventListener('load',function(){ document.getElementById('download').addEventListener('click', download, false); } |
So in this after the load of that web page, element with id “download” is found and click event is bind to it.
The below link shows more details about this exception
Link: http://stackoverflow.com/questions/21262693/addeventlistener-not-working-in-javascript
And we are able to open the provided sample in VS 2010. Kindly check this one again. We have attached sample from the below location
And we have also attached the sample file (Default.aspx, Default.aspx.cs) alone in the below location for your reference
Default.aspx.zip
If you still face any concern, kindly revert back us by modifying the attached sample to replicate the issue. This will help us to fix the issue sooner.
Thanks,
Jayavigneshwaran
Hi Ankur,
Sorry for the inconvenience caused.
We have modified our sample for Visual Studio 2010 and .Net Framework 4.0 and it can be downloaded from the following link
http://www.syncfusion.com/downloads/support/directtrac/118334/ChartExport-1729911475.zip
Note: Since Internet Explorer does not support client-side downloading due to security reasons, Chart will not be exported client-side in Internet explorer
Please let us know if you have any concern.
Regards,
Anandaraj