dharmendra

JavaScript Hook for 'Save as Image'

Recommended Posts

Does a JavaScript hook/function exist for the "Save As Image" menu item to make that publicly available (via actionscript) to the JavaScript API?

 

 

 

We want to create a button on the page so that users can download their chart as a JPEG without having to right-click on the chart itself. Otherwise they may never know that the option to download exists.

Share this post


Link to post
Share on other sites

Hi ,

 

 

 

I want to save the charts as image and then move it into the pdf file using javascript. I downloaded v3 evaluation version .I try to do it the same . But I find an error in FusionCharts.js . When i try save the chart it hows an error "chartToPrint.saveAsImage() does not support method". So Could you please provide the details or any source code?

Share this post


Link to post
Share on other sites

hi,

Though I am writing this long after v3.0.6 launch, since then FusionCharts supports Image saving API call using JavaScript. For this you need to set register with JS option on. That will not give the error that you are mentioning. Please refer to our online documentaion's page  -  http://www.fusioncharts.com/docs/Contents/JS_saveAsImage.html for more on this.

Share this post


Link to post
Share on other sites

Hi ,

 

I did it the same as mentioned in the link( as you provided ) .I throws the javascript error for saveAsImage function .I also set JS variable. I copy the same as mentioned in documentation along with the required changes.I am using evaluation version .This version provides such facility or not .Can you please confirm me. Is there any work around?

 

 

 

Thanks

Share this post


Link to post
Share on other sites

Hi,

I finally figured out what the issue was with the charttoprint object does not support that method or property error in IE that I was receiving.  I figured it out that I have to call registerWithJS on the FlashVars param in order for IE to to acknowledge the OBJECT's id as in: 

so.addParam("FlashVars","&dataURL=cache/myfile.xml&registerWithJS=1");

Once I provided that, it worked fine.  I was relying on the "1" flag on the new instantiation function but it ignores that in IE.  Here's what I ended up using that works:

<SCRIPT LANGUAGE="JavaScript">

  function saveChart(chartID){  

var chartToPrint = getChartFromId(chartID);

chartToPrint.saveAsImage();

  }

</SCRIPT>

<script type="text/javascript">  

var so = new FusionCharts('FusionCharts/Area2D.swf', 'chart1Id','600','400','0','1','FFFFFF','exactFit','','8');

so.addParam("type", "application/x-shockwave-flash");

so.addParam("id", "chart1Id");

so.addParam("FlashVars","&dataURL=cache/myfile.xml&registerWithJS=1");

so.addParam("movie", "FusionCharts/Area2D.swf");

so.addParam("quality", "high");

so.addParam("menu", "true");

so.addParam("wmode", "opaque");  

so.addParam("pluginurl", "http://www.macromedia.com/go/getflashplayer");

so.render("chart1div");

 </script> 

<a href="" onClick="saveChart('chart1Id');">Save Chart</a>

I hop this helps someone out there :).

Edited by Guest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now