Sign in to follow this  
Arindam

chartObj.SetDataURL is not a function

Recommended Posts

Hi,

 

I am displaying multiple charts on a single webpage. I load the first chart page onload and the remaining charts get loaded upon clicks on first or other charts.

 

 

 

Some of the javascript functions look like this ->

 

 

 

 

 

 

 

function updateChart2(id1,id2){

 

 

 

var strURL = "file1.php?id1=" + id1 + "&id2=" +id2;

 

 

 

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

 

 

 

//alert(strURL);

 

 

 

strURL = escape(strURL);

 

 

 

var chartObj = getChartFromId("chart1Id");

 

 

 

chartObj.setDataURL(strURL);

 

 

 

}

 

 

 

 

 

 

 

I call these functions as:

 

 

 

 

 

 

 

id1=2;

 

 

 

id2=3;

 

 

 

updateChart2(id1,id2);

 

 

 

updateChart3(id1,id2);

 

 

 

updateChart4(id1,id2);

 

 

 

 

 

 

 

file1.php, file2.php, fileX.php return either "< chart ..> < / chart>" when no record available OR some values in these chart tags.

 

 

 

If I put following check

 

 

 

 

 

 

 

if(typeof chartObj == '[object]') {

 

 

 

chartObj.setDataURL(strURL);

 

 

 

} else {

 

 

 

alert("Not object");

 

 

 

}

 

 

 

OR

 

 

 

chartObj != Null

 

 

 

chartObj.SetDataURL(strURL)

 

 

 

 

 

then I dont get this error.

 

 

 

 

 

why I get chartObj as null even if I have initialised it with "< chart > .. < / chart>" tags. Because its empty??

 

(I initialise charts in main.php file with empty chart tags and update these with updateChartX functions (as above))

 

 

 

I think I have observed that If I call these functions one per click I dont get the "is not a function" error .. but if I call 3-4 updateChartX functions in one go then If fileX.php returns empty "< chart > .. < / chart>" data then I get this "setDataURL is not a function" error.

 

 

 

How do I debug/solve this? Please help.

 

Thank you.

Share this post


Link to post
Share on other sites

Hi,

Could you please on RegisterWithJS option?

PHP Render:

echo renderChart("../../FusionCharts/Column3D.swf", "", "<chart></chart>", "myFirst", 600, 300, false, true);

Javascript Render:

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

Edited by Guest

Share this post


Link to post
Share on other sites

Thank you for your reply.

 

 

 

Sorry I forgot to mention that I am using Registered = True;

 

render_chart(......., true);

 

 

 

If I do one click per chart ( for example click on chart 1 updates chart 2, click in chart2 updates chart3)

 

then I pass thru check

 

 if(typeof chartObj == 'function' || typof chartObj == 'object') 

 

 

 

WHEN I am IN IF BLOCK and if the data file returns some values I dont get this error and chart gets displayed. IF THERE IS NOT DATA THEN I DONT GET THE "is not a function" error. Thats Perfect.

 

 

 

However things change when I try to call functions in one go

 

 

function updateAll(id) {

updateChart1(id)

updateChart2(id)

updateChart3(id)

}

 

Now if UpdateChart3 has some data it will print otherwise it passes thru above IF CHECK and throughs me error "chartobj.setdataurl is not a function" ??

 

 

 

Please help me how to solve/debug this.

 

Thanks

Edited by Guest

Share this post


Link to post
Share on other sites

I'm having the same error. But only in Firefox. Firebug is returning an error chartObj.setDataURL is not a function when I try to update charts.

 

 

 

I have about 6 charts on a page and use a function to update them all. Now, I think this is the crucial thing, one of my charts is off screen when the page loads. You need to scroll down to view this chart.

 

 

 

If I try to update charts before scrolling down then it fails. If I scroll down to look at the chart, so all charts have been viewed then the function runs fine. It seems as though the bottom chart only initlialises when I look at it on screen as I can see it animating (no matter how long I have waited til I scroll down).

 

 

 

This only happens on FF, not IE. On IE when I scroll down the chart has already animated. Is there a way to force this to animate?

Share this post


Link to post
Share on other sites

While this post has been remarkably helpful, I have hit a wall trying to get my charts working in IE. The fact is, I have 3 charts on a single page. The first chart is the overall data, the second chart is a pie of a specific bar of data, and the third is a Grid to display the Pie Chart's labels more clearly. The object is that when someone clicks on a particular bar in the first chart, then other two refresh displaying the appropriate data. This works perfectly fine in Firefox. In IE the initial 3 charts load fine but then when clicking on a bar I get the following message, "Out of Memory at line: 349". FYI - Line 349 in the HTML View Source points to some static HTML, not to the chart data nor to the Javascript in question.

 

 

 

Here is the code in question (please ignore style, this is currently a proof of concept):

 

 

 

Javascript to refresh the second 2 charts -

 

 

 

function showchart(id) {

 

 

 

if (id == 'projected2009') {

 

var chartObj = getChartFromId("myGrid");

 

chartObj.setDataURL("/recovery/charts/Pie2D2009.xml");

 

var chartObj = getChartFromId("myPie");

 

chartObj.setDataURL("/recovery/charts/Pie2D2009.xml");

 

}

 

else if (id == 'projected2010') {

 

var chartObj = getChartFromId("myGrid");

 

chartObj.setDataURL("/recovery/charts/Pie2D2010.xml");

 

var chartObj = getChartFromId("myPie");

 

chartObj.setDataURL("/recovery/charts/Pie2D2010.xml");

 

}

 

else if (id == 'projected2011') {

 

var chartObj = getChartFromId("myGrid");

 

chartObj.setDataURL("/recovery/charts/Pie2D2011.xml");

 

var chartObj = getChartFromId("myPie");

 

chartObj.setDataURL("/recovery/charts/Pie2D2011.xml");

 

}

 

 

 

}

 

 

 

Chart Generation for second 2 charts -

 

 

 

 

var myGrid = new FusionCharts("/recovery/charts/SSGrid.swf", "myGrid", "300", "180", "0", "1");

 

myGrid.setDataURL("/recovery/charts/Pie2D2009.xml");

 

myGrid.render("gridChart");

 

 

 

var myPie = new FusionCharts("/recovery/charts/Pie2D.swf", "myPie", "260", "180", "0", "1");

 

myPie.setDataURL("/recovery/charts/Pie2D2009.xml");

 

myPie.render("pieChart");

 

 

 

 

Maybe there is a better way? I am not aware of a means to combine the 2 charts together so that they share the same XML. Maybe there are some opinions on where I can look to determine why I am getting a memory issue in IE? Any help would be greatly appreciated. Thank you in advance.

Share this post


Link to post
Share on other sites

Hello Again,

 

 

 

Can I assume that you are referring (in the code provide) to the myPie and myGrid or pieChart and gridChart elements? Or do you have something else in mind? If my assumption is correct, I can attest that these IDs are not being used by any other HTML or Form elements throughout the page, primarily because the rest of the page is just static text. For all intents and purposes, the FusionCharts are the only real elements on the page.

 

 

 

Thanks

Share this post


Link to post
Share on other sites

I am not sure why my previous response isn't showing up, but to answer your question there are no similar IDs on that page. Of course, that is assuming you are referring to the IDs myGrid, gridChart, myPie and pieChart. The rest of the page is more or less static HTML used for testing purposes.

 

 

 

Thanks

Share this post


Link to post
Share on other sites
Guest Madhumita

Hello,

 

 

 

Your assumption is correct. We meant that no two charts must have the same id and no other HTML element in the page should have the same id as any of the charts.

 

 

 

The way you are using a single XML for both the charts is absolutely correct.

 

 

 

It would be really helpful of you if you can send us a scaled down version of your code .

 

 

 

Then we can run a test on it to sort out the issue as soon as possible.

 

 

 

Awaiting your reply. :D

Share this post


Link to post
Share on other sites

Hello Again,

 

 

 

I have attached the files I am using. The only thing, I had to rename my index.html to index.txt to pass your upload filters. If you try this code, you will see that it works perfectly in Firefox, but not so well in IE. I can't understand why this is happening. I have developed a workaround using hidden divs, but this is a terrible solution. Please let me know what you think.

 

 

 

Thanks

 

Dan

chartdata.xml

projected2009.xml

projected2010.xml

projected2011.xml

index.txt

Share this post


Link to post
Share on other sites

Hello Again,

 

 

 

Has any progress been made on this? Are you receiving the same errors I am? I tried recreating the bare minimum project, and I still get the same errors. Please advise.

Share this post


Link to post
Share on other sites
Guest Madhumita

Hello,

56821180-d58b-4b20-a06d-5844.JPG

Could you please set a different name for the two charts, instead of having the chart name same as chart id?

 

e.g.

var myGridJS = new FusionCharts("SSGrid.swf", "myGrid", "300", "180", "0", "1");

myGridJS.setDataURL("projected2009.xml");

myGridJS.render("gridChart");

var myPieJS = new FusionCharts("Pie2D.swf", "myPie", "260", "180", "0", "1");

myPieJS.setDataURL("projected2009.xml");

myPieJS.render("pieChart");

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
Sign in to follow this