Sign in to follow this  
buratino

setDataXML cannot be called

Recommended Posts

I need my chart data to be dynamically changed. To update chart data next code is used:

 


var chartObj = getChartFromId(chartToUpdateId);

chartObj.setDataXML(newDynamicData);

 

But here is what is going on:

 

 

 

chartObj returned by getChartFromId is a function! and thus cannot have setDataXML method...

 

Please help. Where is a mistake? What is wrong here?

 

 

 

Thanks in advance.

Share this post


Link to post
Share on other sites

getChartFromId method returns a reference to the Flash Object in the DOM Model. What error are you getting? Also, can you make sure that your chart is NOT inside a FORM?

Share this post


Link to post
Share on other sites

I use Area2D and Chart2D but it looks like the error occurs for both of them.

 

The page is deployed for debug. Please let me know if you received a link and successfully signed in.

 

 

 

Thank you very much. Appreciating your help.

Share this post


Link to post
Share on other sites

Hi, here is the link

 

 

 

https://213.130.16.232/financial/graph/dashboard

 

 

 

Please log in as 'lohika', password - 'test'.

 

 

 

It is part of a comercial project that is why link is given privately.

 

 

 

On the page there is a chart with no data set on its creation(that is '')

 

 

 

Then javaScript slider component is created for this chart.

 

Slider has event that is triggered on slider position changing (and after slider initialization).

 

This event in our case calls function that updates graph data.

 

The function has to send AJAX request but i simplified that for debugging purposes and simply some stub data is set into the chart.

 

Actually it is no set because error occurs on setDataXml method call. Javascript breaks its execution and i even cannot move the slider

 

 

 

For now as a workaround i recreate chart every time the data has to be updated but what is bad is that chart is blinking on being recreated.

 

 

 

Please let me know if i can somehow assist in solving this problem...

 

If you have any questions feel free to ask (more detail explanation on our JavaScript or any other)..

 

 

 

Thank you very much for you help.

 

 

 

P.S.: It looks like Email button under the posts on this forum doesn't work.. :(

Share this post


Link to post
Share on other sites

Im getting a similar problem, and its coming from the example from the download. From CodeJavaScriptBasicsChangeDataXML.html it errors out in Firefox and IE. When you try to change the data, nothing happens and in firefox the error chartObj.setDataXML is not a function is returned. It errors out in IE also. Ive tried it with the developer package and the evaluation package and I get the error in both packages.

Share this post


Link to post
Share on other sites

Has a solution to this been found? I have a similar problem and thought maybe that it had to do with other javascript files i had included. I use the prototype.js framework/library and thought it might be interfering with fusion charts extensions of javscript's prototype

Share this post


Link to post
Share on other sites

the example works when run from a webserver. Unfortunately, I still have the problem when I try to populate with my actual web page.

 

 

 

I have a JBOSS server running struts. The javascript on the struts page fills data dynamically, but I always get teh cartObj has no properties when I fill it.

 

 

 

I have a page, that initializes the chart with blank data. I use Yahoo YUI widgets which calls the init function after the page is loaded. In the init function, it runs a dwr call to get data. when data come back, i use setDataXML to fill the chart. (Im just using a set string to populate to test). I still get chartObj has no properties.

 

 

 

I have something like this:

 

 

 

function init(){

 

setTimeout("Budget.getChartData(getChartDataReturn)",1500);

 

}

 

YAHOO.util.Event.addListener(window, "load", init);

 

 

 

function getChartDataReturn(data){

 

if(data != null){

 

var chartObj = getChartFromId("chartdiv");

 

chartObj.setDataXML("");

 

 

 

}

 

}

 

 

 

 

 

var myChart = new FusionCharts("${staticServer}/Charts/Doughnut2D.swf", "myChartId", "900", "300", "0", "0");

 

myChart.setDataXML("");

 

myChart.render("chartdiv");

 

Share this post


Link to post
Share on other sites

Im doing all those except the

 

 

 

registerWithJS flag set to 1

 

 

 

Im following the examples you have that change XML with javacsript and I didnt see that flag being set anywhere.

Share this post


Link to post
Share on other sites

Ive don it this way, I still get the error, this is embedded in the JSP so its not a static server error.

 

After init it called, the chart is rendered with No Data. When FC_Rendered is called, I get the chartObj error.

 

 

 

function init(){

 

var myChart = new FusionCharts("${staticServer}/Charts/Doughnut2D.swf", "myChartId", "900", "300", "0", "1");

 

myChart.setDataXML("");

 

myChart.render("chartdiv");

 

}

 

YAHOO.util.Event.addListener(window, "load", init);

 

 

 

function FC_Rendered(domId){

 

if (domId=="chartdiv"){

 

var chartObj = getChartFromId(domId);

 

chartObj.setDataXML("");

 

}

 

return true;

 

}

Share this post


Link to post
Share on other sites

The init function should be called from FC_Rendered. window.load occurs much before the chart is loaded - as the chart is a streaming SWF file.

When the chart is loaded, FC_Rendered method is called - there, you need to call init().

Share this post


Link to post
Share on other sites

The init function is initializing the chart with blank data.

 

 

 

I try to put data in the chart when its loaded with the FC_Rendered function. Isnt FC_Rendered called automatically after the chart is loaded?

 

 

 

function init(){

 

var myChart = new FusionCharts("${staticServer}/Charts/Doughnut2D.swf", "myChartId", "900", "300", "0", "1");

 

myChart.setDataXML("");

 

myChart.render("chartdiv");

 

}

 

YAHOO.util.Event.addListener(window, "load", init);

 

 

 

function FC_Rendered(domId){

 

if (domId=="chartdiv"){

 

var chartObj = getChartFromId(domId);

 

chartObj.setDataXML("");

 

}

 

return true;

 

}

Share this post


Link to post
Share on other sites

Also, please make the following change:

function FC_Rendered(domId){

if (domId=="myChartId"){

var chartObj = getChartFromId(domId);

chartObj.setDataXML("");

}

return true;

}

Share this post


Link to post
Share on other sites

Ah, that was my problem, that fixed it, thanks. Now I have another question :(

 

 

 

When i call the chart through Javascript like that, how do i set:

 

 

 

Share this post


Link to post
Share on other sites

@someone1

 

prototyping only creates a new object. the prototype library should in no way interfere with the prototype method of this architecture.

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