coreyh

Fusion Charts server side export works pefect first time then errors subquent times.

Recommended Posts

ALL FIXED! 6/22/2010

 

 

 

It was the dang chartID, I was dynamicly creating the charts via a loop in a javascript function by appending 'chart'+divID.

 

 

 

But other charts rendered in this same divID thus they got assigned the same chart ID and boom the unspecified error, because it could not locate the chart.

 

 

 

My Fix, since I use Jquery was to use a new library that allowed me to create GUID (Global Unique Identifer) each time the function executed which ensured a new chart ID. The library is located here http://plugins.jquery.com/project/GUID_Helper

 

 

 

I referenced it like so:

 

 

 

var chartID = "chrt_" + $.Guid.New().toString().replaceAll('-', '').toString();

 

 

 

var chart = new FusionCharts(myURL+ "/include/FusionCharts/" + valFlash + ".swf", chartID, valWidth, valHeight, "0", "1");

 

 

 

Thanks for the help, and I hope this helps someone! :w00t:

 

 

 

coreyh (5/26/2010)
This happens on IE 7+

 

 

 

FireFox 3.6.3 works fine.

 

 

 

If I click the export button which executesthe ExportMyChart via jQuery it works like a charm the first time. If I load a another chart it will export fine also, however if I code back to first chart and try to export it again I get the following error in IE8. Any help greatly appreciated.

 

 

 

Attached is error:

  • Click function

 

 

 

$("#lnkPrint").click(function(){

 

var ChartIDs = new Object();

 

ChartTotalExported = 0;

 

ChartTotalIDs = 0;

 

ChartImages = '';

 

if (ChartIDtop != null && ChartIDbottom != null) {

 

ChartIDs = {

 

TopID: ChartIDtop,

 

BottomID: ChartIDbottom

 

};

 

}

 

if (ChartIDtop == null && ChartIDbottom != null) {

 

ChartIDs = {

 

BottomID: ChartIDbottom

 

};

 

}

 

if (ChartIDtop != null && ChartIDbottom == null) {

 

ChartIDs = {

 

TopID: ChartIDtop

 

};

 

}

 

//Export the chart to a jpg

 

ExportMyChart(ChartIDs);

 

});

  • Export Functions

 

 

 

//allows saving of chart to jpg so we can allow user to print or save

 

function ExportMyChart(valChartIDs){

 

var chartObject;

 

 

 

$.each(valChartIDs, function(k, v){

 

chartObject = null;

 

chartObject = getChartFromId(v);

 

 

 

if (chartObject.hasRendered())

 

chartObject.exportChart();

 

ChartTotalIDs += 1;

 

});

 

}

 

 

 

//Callback handler method which is invoked after the chart has saved image on server.

 

function FC_Exported(objRtn){

 

if (objRtn.statusCode == "1") {

 

 

 

ChartTotalExported += 1;

 

 

 

ChartImages += '<img src="' + objRtn.fileName + '"/></br>';

 

 

 

//TODO: Create HTML here we will print or email

 

if (ChartTotalExported == ChartTotalIDs) {

 

alert(ChartImages);

 

}

 

}

 

else {

 

alert("The chart could not be saved on server. There was an error. Description : " + objRtn.statusMessage);

 

}

 

}

post-8901-128441584634_thumb.png

Edited by Guest

Share this post


Link to post
Share on other sites

This is the top and bottomchart ID assignments:

 

 

 

var chart = new FusionCharts(tvHCURL + "/include/FusionCharts/" + valFlash + ".swf", "chart" + valDiv, valWidth, valHeight, "0", "1");

 

chart.setTransparent(true); //this allows other divs to overlay the flash

 

loadAjax(valDiv, valajaxpos);

 

setTimeout(function(){

 

var xml = ''

 

//excute the passed function

 

xml = eval(valFunction);

 

xml = xml.replace("exportHandler='[EXPORT]'", "exportHandler='" + tvHCURL + '/include/FusionCharts/FCExporter.aspx' + "'");

 

 

 

//alert(xml);

 

chart.setDataXML(xml);

 

chart.render(valDiv);

 

//selected chartID's

 

if (valDiv == 'roi-graph') {

 

ChartIDtop = 'chart' + valDiv;

 

}

 

else {

 

ChartIDbottom = 'chart' + valDiv;

 

}

 

 

 

 

 

Thanks for any help!

Share this post


Link to post
Share on other sites

Hey... when you load the second chart, are you hiding the first chart in any way? There is a known issue with Flash movies loosing their "capabilities" when hidden and then brought back.

Share this post


Link to post
Share on other sites

I have the charts loading in divs of course, but I have tab links at the top. So when you click tab1 to render a chart but you are currently viewing the tab2 chart, it passed the div_id to a java script function that just creates the FC xml, passes it to below.

 

 

 

chart.setDataXML(xml);

 

chart.render(valDiv);

 

 

 

shamasis (5/29/2010)
Hey... when you load the second chart, are you hiding the first chart in any way? There is a known issue with Flash movies loosing their "capabilities" when hidden and then brought back.
Edited by Guest

Share this post


Link to post
Share on other sites

Could this be the problem, after I save to jpg the flash object is updated with some call back functions in the swf params but it has crlf's in the params ??

 

 

 

See attached image.

post-8901-128441585403_thumb.jpg

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