bnordeng

Why won't my chart load with setDataURL in Firefox?

Recommended Posts

I have set up a Web page that loads three charts into three separate DIVs.  Two of these are scatter charts and one is a pie chart.  And, I have set up my javascript so that it will show the div with the chart specified and call setDataURL for a chart with certain querystring parameters that return the proper XML.

The code appears to be valid as it is loading the charts, however I have the following problem:

* When I click to update a chart, it gives me a "No data to display" message on the chart.  The second time I click the same chart, it loads the chart just fine.  This problem always happens in Firefox, but rarely in IE (though it does once in a while).

I've also noticed that if I put an alert(''); before the setDataURL() call, then the chart will load on the first click.  This makes me think it is a timing issue.

Any idea on what I am doing wrong?

Share this post


Link to post
Share on other sites

Here is the code...  The charts are displayed on the page inside a DIV (outside the FORM tags):

<div id="divMainChart" style="height:270px;">

<%

  Call renderChart("include/charts/Scatter.swf", "", "<chart caption='' xAxisName='' yAxisName='' lineThickness='1' drawAnchors='0' chartLeftMargin='0' chartRightMargin='0' chartTopMargin='5' chartBottomMargin='0' showValues='0' formatNumberScale='0' showBorder='0' showLegend='0' bgColor='FFFFFF' clickURL=''></chart>", "chartDetail", 570, 275, false, true)

  Call renderChart("include/charts/Scatter.swf", "", "<chart caption='' xAxisName='' yAxisName='' lineThickness='1' drawAnchors='0' chartLeftMargin='0' chartRightMargin='0' chartTopMargin='5' chartBottomMargin='0' showValues='0' formatNumberScale='0' showBorder='0' showLegend='0' bgColor='FFFFFF' clickURL=''></chart>", "chartSummary", 570, 235, false, true)

  Call renderChart("include/charts/Pie2D.swf", "", "<chart caption='' xAxisName='' yAxisName='' lineThickness='1' drawAnchors='0' chartLeftMargin='0' chartRightMargin='0' chartTopMargin='5' chartBottomMargin='0' showValues='0' formatNumberScale='0' showBorder='0' showLegend='0' bgColor='FFFFFF' clickURL=''></chart>", "chartPie", 570, 275, false, true)

%>

</div>

This is the loadChart javascript function that is called when a link is clicked to update the chart...

var sCurrDiv;

  function loadChart(sChartName,bDetail) {

  var sChartDiv;

  sChartDiv = "chartPie";

  displayDiv(sCurrDiv+'Div',0,0);

  displayDiv(sChartDiv+'Div',1,0);

  sCurrDiv = sChartDiv;

  var chartObj = getChartFromId(sChartDiv);

//alert('Hi');

  chartObj.setDataURL(sCurrChart + sQuerystring);

}

If I uncomment the alert('');, forcing a pause before the setDataURL is called then the chart loads fine after I click OK on the alert popup.  However, without the alert I get a "No Data to Display." message where the chart should be (in Firefox).  Usually, in IE it works, however it provides the same error in IE on occassion.

Share this post


Link to post
Share on other sites

I've tried using the escape function so that my setDataURL call now looks like this...

chartObj.setDataURL(escape(sCurrChart + sQuerystring));

I am getting the same result.  It appears that the proper information is being sent because I only get the "No Data to Display" message on my first click of the link.  On the second click, the chart loads fine.  This makes me think it is some kind of timing issue.  And, I'm wondering if anyone has previously experienced a problem like this with FusionCharts.

It's frustrating because it works in IE 99% of the time, but in Firefox it never works.  And, of course, our site must be fully functional with both of these browsers.

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