freeyland

chartObj.setDataURL is not a function error in PHP examples

Recommended Posts

When running in the examples folder:

 

CodePHPDB_JS_dataURLDefault.php

 

 

 

I am getting the following javascript error: chartObj.setDataURL is not a function

 

 

 

What I already tried:

 

1) Update to the latest fusioncharts version

 

2) Set JS to true

 

echo renderChart("../../FusionCharts/Column2D.swf?ChartNoDataText=Please select a factory from pie chart above to view detailed data.", "", "", "FactoryDetailed", 600, 250, false, true);

 

 

 

3)function FC_Rendered(DOMId){

 

WHen added this function it looks like the second grap never get fully loaded

 

But non of them seems to help

 

 

 

Thx for the help

Share this post


Link to post
Share on other sites
Guest Madhumita

Hello,

You might get this error for several reasons.

If you call the setDataURL method on the chart before it even gets rendered, this might be a problem.

If you could attach your codes we will test and let you know the exact solution.

Share this post


Link to post
Share on other sites

The code is the sample code which is provided in the package.

 

 

 

I both tried :

 

 

 

echo renderChart("../../FusionCharts/Column2D.swf?ChartNoDataText=Please select a factory from pie chart above to view detailed data.", "", "", "FactoryDetailed", 600, 250, false, true);

 

==> Page keeps loading without graph displayed

 

 

 

echo renderChart("../../FusionCharts/Column2D.swf?ChartNoDataText=Please select a factory from pie chart above to view detailed data.", "", "", "FactoryDetailed", 600, 250, false, false);

 

=> Error: chartObj.setDataURL is not a function

 

 

 

I both tried in IE and Firefox

graph.txt

Share this post


Link to post
Share on other sites

Hi,

 

 

 

We have tested your code its working fine.

 

Could you please delete this line and try again?

 

echo renderChart("Column2D.swf?ChartNoDataText=Please select a factory from pie chart above to view detailed data.", "", "", "FactoryDetailed", 600, 250, false, false);

 

 

Hope this helps.

 

 

 

Regards,

 

Rohit Kumar

 

 

 

Coming to CeBIT 2010, Hannover? Visit us at Hall 6, Webciety Booth K33. We would love to see you there.

Share this post


Link to post
Share on other sites

Hi,

 

It is working now.

 

 

 

It was a combination of the last parameter putting to 'true' and an error the example file 'Factory.php'

 

Following was missing:

 

include("../Includes/FusionCHarts.php");

 

 

 

Thank you very much!!!

Share this post


Link to post
Share on other sites

I have the same error.  I deleted the code and re-copied it from the online documentation as you suggested but still get the same error.

echo

renderChart("../../FusionCharts/Column2D.swf?ChartNoDataText=Please select a factory from pie chart above to view detailed data.", "", "<chart></chart>", "FactoryDetailed", 600, 250, false, false);

Any help will be greatly appreciated.

Thanks!

 

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

Welcome to FusionCharts forum. :)

Could you please specify the issue a bit elaborately?

Share this post


Link to post
Share on other sites

Thank you for the quick reply.  I am following the PHP, JavaScript & dataURL example in the FusionCharts v3 online documentation.  It is located in the Guide for Web Developers folder, under Using with PHP folder.  This web page opens with a pie chart already populated and allows the user to drill down and get detailed information shown in a bar chart below.  The error occurs when you click a peice of the pie to populate the detailed bar chart below.  The error is "chartObj.setDataURL is not a function".  Here is the javascript function code:

<SCRIPT LANGUAGE="JavaScript">

  /**

* updateChart method is invoked when the user clicks on a pie slice.

* In this method, we get the index of the factory after which we request for XML data

* for that that factory from FactoryData.php, and finally

* update the Column Chart.

* @param factoryIndex Sequential Index of the factory.

*/

function updateChart(factoryIndex){

 //DataURL for the chart

 var strURL = "FactoryData.php?factoryId=" + factoryIndex;

 

 //Sometimes, the above URL and XML data gets cached by the browser.

 //If you want your charts to get new XML data on each request,

 //you can add the following line:

 //strURL = strURL + "&currTime=" + getTimeForURL();

 //getTimeForURL method is defined below and needs to be included

 //This basically adds a ever-changing parameter which bluffs

 //the browser and forces it to re-load the XML data every time.

 

 //URLEncode it - NECESSARY.

 strURL = escape(strURL);

 

 //Get reference to chart object using Dom ID "FactoryDetailed"

 var chartObj = getChartFromId("FactoryDetailed");

 //Send request for XML

 chartObj.setDataURL(strURL);

The underlined code is where the error occurs.  I looked in the FusionCharts.js file and confirmed that the setDataURL function is there.  I double checked and made sure that I had an include statement for this file as well.

Thank you for your assistance.

Karl

Edited by Guest

Share this post


Link to post
Share on other sites

I solved the problem. The problem lies in where the chart is rendered. echo renderChart("../../FusionCharts/Column2D.swf?ChartNoDataText=Please select a factory from pie chart above to view detailed data.", "", "", "RegionDetailed", 600, 250, false, false); This is the code that is supplied in the online documentation. It is incorrect, the words false need to be replaced by a 0 and a 1 for this to work. I discovered this further in the online documentation under FusionCharts and Javascript/JavaScript API's exposed. There is a little warning on the top of the page: "Please note that the events are raised only when registerWithJS flag of the chart is set to 1". If you then click on the API Method Signature setDataURL(strDataURL:String) link you will find an example with the 0 and 1.

Share this post


Link to post
Share on other sites
Guest Basundhara Ghosal

Hi,

Thanks for sharing the solution.

We are glad to know that your issue is resolved.

Happy FusionCharting. :)

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