hungtrieu2910

Javascript error for 'save as image'

Recommended Posts

I am tring to to save the chart as an image .I also included the FusionCharts.js properly. even though it is throwing javascript error like chartToPrint.saveAsImage() function is not defined. I am using fusion chart 2.0.5 version.I searched saveAsImage() function in FusionCharts.js .It was not present there. Anyone can provide me the FusionCharts.js which includes saveAsImage () function Or any other solution .

 

 

 

Thanks in advance

Share this post


Link to post
Share on other sites

Hi,

 

 

 

Can you please provide the me the code of saveAsImage() function of FusionCharts.js which is updated in v3.0.6?

 

I will be very thankful to you.

 

 

 

Thanks

Share this post


Link to post
Share on other sites

Hi ,

 

 

 

Actually, i am using the evaluation version of v3 which is presently available at your site . And I also used the same information as you provided the link for saveAsImage function . I copy the whole example as it is mentioned in the link. It fails at the line chartToPrint.saveAsImage();and gives the error 'chartToPrint.saveAsImage() is not a function' in error console.So, I just want to confirm that this facility (save as image ) is available in evaluation version or not. If not ,then how can i achieve this facility.Please provide me exact solution.

 

 

 

Thanks

Share this post


Link to post
Share on other sites

Hi Sudipto,

 

I have Adobe flash version 9.I am running the same on server. Even though it is not working . Can you please tell me saveAsImage function should be present in FusionCharts.js or not. If yes ,then it is not available in evaluation version.

 

I am also attached the code.Please look into this .

 

 

 

 

 

function saveChart(){

 

//Get chart from its ID

 

var chartToPrint = getChartFromId("chart1Id");

 

chartToPrint.saveAsImage();

 

}

 

 

 

and

 

 

 

var chart1 = new FusionCharts("../FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1");

 

chart1.setDataXML("");

 

chart1.render("chart1div");

 

 

 

and the data.xml is

 

chart imageSave='1' imageSaveURL='http://localhost:8080/jsp-examples/FusionCharts/MyFirstChart/ImageSaving/FusionChartsSave.jsp'>

 

 

 

 

 

 

Everything is in the path.Please look into this.

 

 

 

Thanks

Edited by Guest

Share this post


Link to post
Share on other sites

Hi,

There are some functions in FusionCharts which are exposed and can be accessed from the chart itself. Flash techies call this externalInterface functions. We can use JavaScript to call these functions directly. saveAsImage() is one of these functions. Hence, you would not get this entry in FusionCharts.js. But, if you use FusionCharts SWFs whose version is v3.0.6 you would definitely get this featute. Could you please check whether you have the specified version of chart SWF files. To know your version to this precision 3.x.x, please render a chart with debug mode on. In the debug window you would get the version info.

Share this post


Link to post
Share on other sites

Hi Sudipto,

 

 

 

You are right .Actually i looked into the version of swf files it was of version 3.0.3 .I copied the latest swf files .It is working fine now. I have one question. I would like to know the link where all methods are given like FC_render etc.Can you please provide me.

 

 

 

Thanks a lot.

Share this post


Link to post
Share on other sites

I had the same problem, but I have corrected it. My problem is I forgot set 'registerWithJS' flag to 1 instead 0.

 

Make sure you specify:

 

 

 

var chart1 = new FusionCharts("../../FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "1");

 

 

 

not:

 

 

 

var chart1 = new FusionCharts("../../FusionCharts/Column3D.swf", "chart1Id", "400", "300", "0", "0");

 

 

 

Please notice different between the last value of two statement above (1 vs 0). When I change the last value from 0 to 1, function saveAsImage() work fine.

Share this post


Link to post
Share on other sites

I have a same error!

 

 

 

Declaration of chart appear correctly:

 

 

var chart_versusChart = new FusionCharts("/FusionCharts/Pie3D.swf?registerWithJS='1'", "versusChart", "100%", "100%", "0", "1");

 

chart_versusChart.setDataXML("

Share this post


Link to post
Share on other sites

Hi,

I am afraid, your declaration of chart is not correct:

var chart_versusChart = new FusionCharts("/FusionCharts/Pie3D.swf?registerWithJS='1'", "versusChart", "100%", "100%", "0", "1");

chart_versusChart.setDataXML("");

chart_versusChart.render("versusChartDiv");

 

It should be:

 

var chart_versusChart = new FusionCharts("/FusionCharts/Pie3D.swf?", "versusChart", "100%", "100%", "0", "1");

chart_versusChart.setDataXML("");

chart_versusChart.render("versusChartDiv");

Please avoid using ' (quote) or " (double quote) in a query string. And if you are passing 1 to the last parameter then there is no need to passing registerWithJS=1 from query string.

Share this post


Link to post
Share on other sites

Hi,

 

after changes, function saveAsImage works. But function view2D don't.

 

 

 

Error:

 

chartToView2D.view2D is not a function

 

 

 

 

 

My functions:

 

 

function viewAs2D() {

 

//Get chart from its ID

 

var chartToView2D = getChartFromId("versusChart");

 

chartToView2D.view2D();

 

}

 

function viewAs3D() {

 

//Get chart from its ID

 

var chartToView3D = getChartFromId("versusChart");

 

chartToView2D.view3D();

 

}

 

function saveChart() {

 

//Get chart from its ID

 

var chartToPrint = getChartFromId("versusChart");

 

chartToPrint.saveAsImage();

 

}

 

 

 

 

JS now:

 

 

var chart_versusChart = new FusionCharts("/FusionCharts/Pie3D.swf", "versusChart", "100%", "100%", "0", "1");

 

chart_versusChart.setDataXML("

Share this post


Link to post
Share on other sites

Hi,

 

 

 

I am afraid, the docs you are viewing is for MultiSeries Combination 3D Chart (mscombi3d.swf) and the chart you are using is a (pie3d.swf), please see your code below.

 

 

 

var chart_versusChart = new FusionCharts("/FusionCharts/Pie3D.swf", "versusChart", "100%", "100%", "0", "1");

 

chart_versusChart.setDataXML("");

 

chart_versusChart.render("versusChartDiv");

 

 

 

Also please note that pie chart does not support this features.

Edited by Guest

Share this post


Link to post
Share on other sites

I have a same error!

 

 

 

Declaration of chart appear correctly:[p]

 

var myChart = new FusionCharts("D:Program FilesTomcat 5.5webappsFusionCImageSaveWebContentChartsColumn3D.swf", "chart1Id", "400", "200", "0", "1");

 

myChart.setDataURL("D:Program FilesTomcat 5.5webappsFusionCImageSavedocumentxmlfile.xml");

 

myChart.render("chart1div");

 

[/p]

 

 

 

My JS functions:[p]

 

var chartToPrint = getChartFromId("chart1Id");

 

alert(chartToPrint);

 

chartToPrint.saveAsImage();

 

[/p]

 

Error in button click:

 

chartToPrint.saveAsImage is not a function

 

 

 

 

 

My SFW version

 

 

 

FusionCharts v3,

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