avernet

chartObj.setDataXML is not a function

Recommended Posts

I am using FusionCharts 3.1, and set the XML for the chart with JavaScript with the setDataXML() method. It works fine, and the chart shows as expected. Later on the same page, I call the setDataXML() method again to update the chart, and get the JavaScript error "chartObj.setDataXML is not a function".

 

 

 

I added some debug code to FusionChart.js, in "else" part of setDataXML(). The variable chartObj correctly points to the object as expected, but setDataXML() is undefined on that object. Any idea of why this would be the case?

 

 

 

Alex

Share this post


Link to post
Share on other sites
Sudipto Choudhury (7/7/2009)
Hi,

 

 

 

Could you please see whether you have set the RegisterWithJS parameter to "1" ?

 

 

 

That was it! I didn't have the RegisterWithJS=1, and in fact didn't even know about it before reading your message :). This the call to setDataXML() goes through and the chart "re-draws", but it isn't updated: even if the data I provide is different, I get exactly the same chart. Any reason why this could be happening?

 

 

 

Alex

Share this post


Link to post
Share on other sites

A workaround is to just recreate the FusionCharts object every time I need to update it, instead of reusing it. Is there any downside in recreating the FusionCharts object this way?

 

 

 

Alex

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

 

 

 

In your update chart code simply write:

 

 

 

getChartFromId("chart_display").setDataXML(xmlData);

 

 

 

or if you have received the response text in URLEncoded form :

 

 

 

getChartFromId("chart_display").setDataXML(unesape(xmlData));

 

 

 

Note: You would need to render the chart ONCE bofore you can update it.

 

 

 

I hope this helps. :)

Share this post


Link to post
Share on other sites

Rajroop,

 

 

 

Ah, you found it: I was calling render() every time after calling setDataXML(), and apparently when doing so the chart renders with the initial data. Like you said, render() must be called once, after the initial call to setDataXML().

 

 

 

Alex

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